window.storecrm_config = {"backendUrl":"https://obake.groovymedia.co","appProxyName":"obake"}; (()=>{"use strict";var t={208:(t,e,n)=>{n.d(e,{A:()=>a});var o=n(601),i=n.n(o),r=n(314),s=n.n(r)()(i());s.push([t.id,".storecrm_modal {\n display: none;\n}\n\n.storecrm_modal.is-open {\n display: block;\n}\n\n.storecrm_modal_line {\n margin: 1rem 0;\n}\n\n.storecrm_modal_line label {\n display: flex;\n align-items: center;\n}\n\n#storecrm_restock_accepts_marketing {\n margin: 0 5px 0 0;\n max-width: 15px;\n}\n\n@media (hover: hover) {\n .storecrm_modal_line label:hover {\n cursor: pointer;\n }\n #storecrm_restock_accepts_marketing:hover {\n cursor: pointer;\n }\n}\n\n.storecrm_modal input,\n.storecrm_modal select {\n width: 100%;\n padding: 10px;\n font-size: 100%;\n margin: 1rem 0;\n}\n\n.storecrm_modal__overlay {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 10000;\n background: rgba(0, 0, 0, 0.6);\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.storecrm_modal__container {\n background-color: #fff;\n padding: 30px;\n min-width: 320px;\n max-width: 500px;\n min-height: 200px;\n max-height: 100vh;\n border-radius: 4px;\n overflow-y: auto;\n box-sizing: border-box;\n}\n\n.storecrm_modal__header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n.storecrm_modal__title {\n margin-top: 0;\n margin-bottom: 0;\n font-weight: 600;\n font-size: 1.25;\n line-height: 1.25;\n box-sizing: border-box;\n}\n\n.storecrm_modal__close {\n background: transparent;\n border: 0;\n cursor: pointer;\n}\n\n.storecrm_modal_message {\n margin-top: 2rem;\n padding: 1rem;\n}\n\n.storecrm_modal__header .storecrm_modal__close:before {\n content: '\\2715';\n}\n\n.storecrm_modal__content {\n margin-top: 2rem;\n margin-bottom: 1rem;\n line-height: 1.5;\n color: rgba(0, 0, 0, 0.8);\n}\n\n.storecrm_modal__btn {\n display: block;\n width: 100%;\n padding-top: 1rem;\n padding-bottom: 1rem;\n background-color: #e6e6e6;\n color: rgba(0, 0, 0, 0.8);\n border-radius: 0.25rem;\n border-style: none;\n border-width: 0;\n cursor: pointer;\n -webkit-appearance: button;\n text-transform: none;\n overflow: visible;\n line-height: 1.15;\n margin: 0;\n margin-top: 1rem;\n will-change: transform;\n -moz-osx-font-smoothing: grayscale;\n -webkit-backface-visibility: hidden;\n backface-visibility: hidden;\n -webkit-transform: translateZ(0);\n transform: translateZ(0);\n transition: -webkit-transform 0.25s ease-out;\n transition: transform 0.25s ease-out;\n transition: transform 0.25s ease-out, -webkit-transform 0.25s ease-out;\n}\n\n.storecrm_modal__btn:hover {\n -webkit-transform: scale(1.05);\n transform: scale(1.05);\n}\n\n.storecrm_modal__btn-primary {\n background-color: #00449e;\n color: #fff;\n}\n\n.storecrm_modal__btn:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n@keyframes mmfadeIn {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n\n@keyframes mmfadeOut {\n from {\n opacity: 1;\n }\n to {\n opacity: 0;\n }\n}\n\n@keyframes mmslideIn {\n from {\n transform: translateY(15%);\n }\n to {\n transform: translateY(0);\n }\n}\n\n@keyframes mmslideOut {\n from {\n transform: translateY(0);\n }\n to {\n transform: translateY(-10%);\n }\n}\n\n.micromodal-slide {\n display: none;\n}\n\n.micromodal-slide.is-open {\n display: block;\n}\n\n.micromodal-slide[aria-hidden='false'] .storecrm_modal__overlay {\n animation: mmfadeIn 0.3s cubic-bezier(0, 0, 0.2, 1);\n}\n\n.micromodal-slide[aria-hidden='false'] .storecrm_modal__container {\n animation: mmslideIn 0.3s cubic-bezier(0, 0, 0.2, 1);\n}\n\n.micromodal-slide[aria-hidden='true'] .storecrm_modal__overlay {\n animation: mmfadeOut 0.3s cubic-bezier(0, 0, 0.2, 1);\n}\n\n.micromodal-slide[aria-hidden='true'] .storecrm_modal__container {\n animation: mmslideOut 0.3s cubic-bezier(0, 0, 0.2, 1);\n}\n\n.micromodal-slide .storecrm_modal__container,\n.micromodal-slide .storecrm_modal__overlay {\n will-change: transform;\n}\n\n/* \u30d5\u30a7\u30fc\u30c9\u30a4\u30f3\u30fb\u30d5\u30a7\u30fc\u30c9\u30a2\u30a6\u30c8\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u7528\u306e\u30af\u30e9\u30b9 */\n.fade-out {\n animation: mmfadeOut 0.3s cubic-bezier(0, 0, 0.2, 1) forwards;\n}\n\n.fade-in {\n animation: mmfadeIn 0.3s cubic-bezier(0, 0, 0.2, 1) forwards;\n}\n\n.storecrm-status-widget {\n width: 100%;\n border: 1px solid #e6e6e6;\n display: flex;\n align-items: center;\n justify-content: center;\n max-height: 3em;\n}\n\n.storecrm-status-widget > div {\n padding: 1rem;\n}\n\n@media (max-width: 767px) {\n .storecrm-status-widget {\n flex-direction: column;\n max-height: none; /* Remove height restriction */\n }\n}\n\n.storecrm-status-widget button {\n margin-left: 0.5rem;\n}\n\n.storecrm-on {\n /* deep green, bold */\n color: #094c00;\n font-weight: bold;\n}\n\n.storecrm-off {\n color: #df8536c6;\n font-weight: bold;\n}\n\n.line-chat-preview {\n display: flex;\n flex-direction: column;\n width: 360px;\n height: 640px;\n border: 1px solid #ddd;\n overflow: hidden;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\n box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);\n background-color: #92aad4;\n}\n\n.line-chat-header {\n display: flex;\n align-items: center;\n padding: 10px 16px;\n background-color: #44556f;\n color: white;\n height: 50px;\n}\n\n.line-chat-body {\n flex-grow: 1;\n overflow-y: auto;\n display: flex;\n flex-direction: column;\n gap: 8px;\n position: relative;\n scrollbar-width: none;\n -ms-overflow-style: none;\n}\n\n.line-chat-body::-webkit-scrollbar {\n display: none;\n}\n\n.line-chat-footer {\n padding: 0 16px 0 16px;\n background-color: #ffffff;\n display: flex;\n align-items: center;\n justify-content: space-between;\n height: 50px;\n}\n\n.line-chat-keyboard-icon {\n width: 22px;\n height: 22px;\n}\n\n.line-chat-chatbarText {\n flex-grow: 1;\n font-size: 14px;\n color: #000;\n text-align: center;\n}\n\n/* \u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u8868\u793a\u6642\u306e\u30b9\u30bf\u30a4\u30eb */\n.line-chat-footer.menu-open .line-chat-chatbarText:after {\n content: '\u25bc';\n}\n\n/* \u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u975e\u8868\u793a\u6642\u306e\u30b9\u30bf\u30a4\u30eb */\n.line-chat-footer:not(.menu-open) .line-chat-chatbarText:after {\n content: '\u25b2';\n}\n\n.line-richmenu-preview {\n position: absolute;\n bottom: 0;\n left: 0;\n right: 0;\n background-color: #ffffff;\n transform: translateY(100%);\n transition: transform 0.3s cubic-bezier(0, 0, 0.2, 1);\n z-index: 10;\n box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);\n}\n\n.line-richmenu-preview.menu-open {\n transform: translateY(0);\n}\n\n.line-richmenu-preview.menu-closed {\n transform: translateY(100%);\n}\n\n/* LINE\u518d\u5165\u8377\u901a\u77e5\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u7528\u306e\u30b9\u30bf\u30a4\u30eb */\n.storecrm-line-restock-popup-overlay {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 10000;\n background: rgba(0, 0, 0, 0.6);\n display: flex;\n justify-content: center;\n align-items: center;\n opacity: 0;\n animation: mmfadeIn 0.3s cubic-bezier(0, 0, 0.2, 1) forwards;\n}\n\n.storecrm-line-restock-popup {\n background-color: #fff;\n padding: 30px;\n min-width: 320px;\n max-width: 500px;\n min-height: 150px;\n max-height: 100vh;\n border-radius: 8px;\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n box-sizing: border-box;\n text-align: center;\n overflow-y: auto;\n transform: translateY(15%);\n animation: mmslideIn 0.3s cubic-bezier(0, 0, 0.2, 1) forwards;\n will-change: transform;\n}\n\n.storecrm-line-restock-popup-text {\n font-size: 16px;\n line-height: 1.5;\n margin-bottom: 20px;\n color: rgba(0, 0, 0, 0.8);\n font-weight: 500;\n}\n\n.storecrm-line-restock-popup-button {\n display: block;\n width: 100%;\n padding: 12px 16px;\n background-color: #3b82f6;\n color: white;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n font-weight: 600;\n will-change: transform;\n backface-visibility: hidden;\n transform: translateZ(0);\n transition: transform 0.25s ease-out, background-color 0.2s ease;\n}\n\n.storecrm-line-restock-popup-button:hover {\n background-color: #2563eb;\n transform: scale(1.02);\n}\n\n.storecrm-line-restock-popup-button:active {\n transform: scale(0.98);\n}\n\n.storecrm-line-restock-popup-button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n transform: none;\n}\n\n/* \u9589\u3058\u308b\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u7528\u306e\u30af\u30e9\u30b9 */\n.storecrm-line-restock-popup-overlay.fade-out {\n animation: mmfadeOut 0.3s cubic-bezier(0, 0, 0.2, 1) forwards;\n}\n\n.storecrm-line-restock-popup-overlay.fade-out .storecrm-line-restock-popup {\n animation: mmslideOut 0.3s cubic-bezier(0, 0, 0.2, 1) forwards;\n}\n\n/* \u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u5b9a\u7fa9 */\n@keyframes mmfadeIn {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n\n@keyframes mmfadeOut {\n from {\n opacity: 1;\n }\n to {\n opacity: 0;\n }\n}\n\n@keyframes mmslideIn {\n from {\n transform: translateY(15%);\n }\n to {\n transform: translateY(0);\n }\n}\n\n@keyframes mmslideOut {\n from {\n transform: translateY(0);\n }\n to {\n transform: translateY(-10%);\n }\n}\n\n/* \u30ec\u30b9\u30dd\u30f3\u30b7\u30d6\u5bfe\u5fdc */\n@media (max-width: 480px) {\n .storecrm-line-restock-popup {\n min-width: 280px;\n max-width: 90vw;\n padding: 20px;\n margin: 0 15px;\n }\n\n .storecrm-line-restock-popup-text {\n font-size: 14px;\n margin-bottom: 15px;\n }\n\n .storecrm-line-restock-popup-button {\n padding: 10px 14px;\n font-size: 13px;\n }\n}\n",""]);const a=s},314:t=>{t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",o=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),o&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),o&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,o,i,r){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(o)for(var a=0;a0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=r),n&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=n):d[2]=n),i&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=i):d[4]="".concat(i)),e.push(d))}},e}},601:t=>{t.exports=function(t){return t[1]}},804:(t,e,n)=>{function o(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,o=new Array(e);nh});var s,a,c,l,d,u=(s=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',"select:not([disabled]):not([aria-hidden])","textarea:not([disabled]):not([aria-hidden])","button:not([disabled]):not([aria-hidden])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'],a=function(){function t(e){var n=e.targetModal,o=e.triggers,r=void 0===o?[]:o,s=e.onShow,a=void 0===s?function(){}:s,c=e.onClose,l=void 0===c?function(){}:c,d=e.openTrigger,u=void 0===d?"data-micromodal-trigger":d,h=e.closeTrigger,m=void 0===h?"data-micromodal-close":h,p=e.openClass,f=void 0===p?"is-open":p,g=e.disableScroll,b=void 0!==g&&g,v=e.disableFocus,_=void 0!==v&&v,y=e.awaitCloseAnimation,w=void 0!==y&&y,k=e.awaitOpenAnimation,x=void 0!==k&&k,S=e.debugMode,E=void 0!==S&&S;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.modal=document.getElementById(n),this.config={debugMode:E,disableScroll:b,openTrigger:u,closeTrigger:m,openClass:f,onShow:a,onClose:l,awaitCloseAnimation:w,awaitOpenAnimation:x,disableFocus:_},r.length>0&&this.registerTriggers.apply(this,i(r)),this.onClick=this.onClick.bind(this),this.onKeydown=this.onKeydown.bind(this)}var e,n;return e=t,(n=[{key:"registerTriggers",value:function(){for(var t=this,e=arguments.length,n=new Array(e),o=0;o0&&void 0!==arguments[0]?arguments[0]:null;if(this.activeElement=document.activeElement,this.modal.setAttribute("aria-hidden","false"),this.modal.classList.add(this.config.openClass),this.scrollBehaviour("disable"),this.addEventListeners(),this.config.awaitOpenAnimation){this.modal.addEventListener("animationend",(function e(){t.modal.removeEventListener("animationend",e,!1),t.setFocusToFirstNode()}),!1)}else this.setFocusToFirstNode();this.config.onShow(this.modal,this.activeElement,e)}},{key:"closeModal",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=this.modal;if(this.modal.setAttribute("aria-hidden","true"),this.removeEventListeners(),this.scrollBehaviour("enable"),this.activeElement&&this.activeElement.focus&&this.activeElement.focus(),this.config.onClose(this.modal,this.activeElement,t),this.config.awaitCloseAnimation){var n=this.config.openClass;this.modal.addEventListener("animationend",(function t(){e.classList.remove(n),e.removeEventListener("animationend",t,!1)}),!1)}else e.classList.remove(this.config.openClass)}},{key:"closeModalById",value:function(t){this.modal=document.getElementById(t),this.modal&&this.closeModal()}},{key:"scrollBehaviour",value:function(t){if(this.config.disableScroll){var e=document.querySelector("body");switch(t){case"enable":Object.assign(e.style,{overflow:""});break;case"disable":Object.assign(e.style,{overflow:"hidden"})}}}},{key:"addEventListeners",value:function(){this.modal.addEventListener("touchstart",this.onClick),this.modal.addEventListener("click",this.onClick),document.addEventListener("keydown",this.onKeydown)}},{key:"removeEventListeners",value:function(){this.modal.removeEventListener("touchstart",this.onClick),this.modal.removeEventListener("click",this.onClick),document.removeEventListener("keydown",this.onKeydown)}},{key:"onClick",value:function(t){(t.target.hasAttribute(this.config.closeTrigger)||t.target.parentNode.hasAttribute(this.config.closeTrigger))&&(t.preventDefault(),t.stopPropagation(),this.closeModal(t))}},{key:"onKeydown",value:function(t){27===t.keyCode&&this.closeModal(t),9===t.keyCode&&this.retainFocus(t)}},{key:"getFocusableNodes",value:function(){var t=this.modal.querySelectorAll(s);return Array.apply(void 0,i(t))}},{key:"setFocusToFirstNode",value:function(){var t=this;if(!this.config.disableFocus){var e=this.getFocusableNodes();if(0!==e.length){var n=e.filter((function(e){return!e.hasAttribute(t.config.closeTrigger)}));n.length>0&&n[0].focus(),0===n.length&&e[0].focus()}}}},{key:"retainFocus",value:function(t){var e=this.getFocusableNodes();if(0!==e.length)if(e=e.filter((function(t){return null!==t.offsetParent})),this.modal.contains(document.activeElement)){var n=e.indexOf(document.activeElement);t.shiftKey&&0===n&&(e[e.length-1].focus(),t.preventDefault()),!t.shiftKey&&e.length>0&&n===e.length-1&&(e[0].focus(),t.preventDefault())}else e[0].focus()}}])&&o(e.prototype,n),t}(),c=null,l=function(t){if(!document.getElementById(t))return console.warn("MicroModal: \u2757Seems like you have missed %c'".concat(t,"'"),"background-color: #f8f9fa;color: #50596c;font-weight: bold;","ID somewhere in your code. Refer example below to resolve it."),console.warn("%cExample:","background-color: #f8f9fa;color: #50596c;font-weight: bold;",'')),!1},d=function(t,e){if(function(t){t.length<=0&&(console.warn("MicroModal: \u2757Please specify at least one %c'micromodal-trigger'","background-color: #f8f9fa;color: #50596c;font-weight: bold;","data attribute."),console.warn("%cExample:","background-color: #f8f9fa;color: #50596c;font-weight: bold;",''))}(t),!e)return!0;for(var n in e)l(n);return!0},{init:function(t){var e=Object.assign({},{openTrigger:"data-micromodal-trigger"},t),n=i(document.querySelectorAll("[".concat(e.openTrigger,"]"))),o=function(t,e){var n=[];return t.forEach((function(t){var o=t.attributes[e].value;void 0===n[o]&&(n[o]=[]),n[o].push(t)})),n}(n,e.openTrigger);if(!0!==e.debugMode||!1!==d(n,o))for(var r in o){var s=o[r];e.targetModal=r,e.triggers=i(s),c=new a(e)}},show:function(t,e){var n=e||{};n.targetModal=t,!0===n.debugMode&&!1===l(t)||(c&&c.removeEventListeners(),(c=new a(n)).showModal())},close:function(t){t?c.closeModalById(t):c.closeModal()}});"undefined"!=typeof window&&(window.MicroModal=u);const h=u},511:(t,e,n)=>{n.r(e),n.d(e,{default:()=>b});var o=n(72),i=n.n(o),r=n(825),s=n.n(r),a=n(659),c=n.n(a),l=n(56),d=n.n(l),u=n(540),h=n.n(u),m=n(113),p=n.n(m),f=n(208),g={};g.styleTagTransform=p(),g.setAttributes=d(),g.insert=c().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=h();i()(f.A,g);const b=f.A&&f.A.locals?f.A.locals:void 0},72:t=>{var e=[];function n(t){for(var n=-1,o=0;o{var e={};t.exports=function(t,n){var o=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(n)}},540:t=>{t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},56:(t,e,n)=>{t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},825:t=>{t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var o="";n.supports&&(o+="@supports (".concat(n.supports,") {")),n.media&&(o+="@media ".concat(n.media," {"));var i=void 0!==n.layer;i&&(o+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),o+=n.css,i&&(o+="}"),n.media&&(o+="}"),n.supports&&(o+="}");var r=n.sourceMap;r&&"undefined"!=typeof btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleTagTransform(o,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},113:t=>{t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},989:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.schema=e.renderWidgetSelector=e.hideWidgetSelector=e.render=e.getIcon=void 0;e.getIcon=(t,e=!1)=>{let n=null;return"star"===t.buttonicon?n=e?'':'':"heart"===t.buttonicon?n=e?'':'':"tag"===t.buttonicon?n='':"clip"===t.buttonicon&&(n=''),n&&(n=n.replace("viewBox",`width="${t.icon_size}" height="${t.icon_size}" style="margin-right: ${t.icon_margin}px;" viewBox`)),n};class n{constructor(t,e,n,o,i,r=!1,s=!1,a){this.eventTriggered=!1,this.variants=n,this.buttonSettings=Object.assign({},o),this.productId=e,this.button=i,this.isFavorited=r,this.hasVariantSelector=s,this.variantId=a,this.buttonSettings.has_background||(this.buttonSettings.button_width="auto",this.buttonSettings.button_height="auto",this.buttonSettings.button_radius=0,this.buttonSettings.button_border_width=0,this.buttonSettings.button_background_color="transparent",this.buttonSettings.button_border_color="transparent",this.buttonSettings.button_hover_border_color="transparent",this.buttonSettings.button_hover_background_color="transparent")}static getInstance(t,e,o,i,r,s=!1,a=!1,c){return n.instances[t]?(n.instances[t].isFavorited=s,n.instances[t].hasVariantSelector=a):n.instances[t]=new n(t,e,o,i,r,s,a,c),n.instances[t]}checkRender(t){document.querySelectorAll(`.storecrm-wishlistbutton-${t}`).forEach((t=>{if(t instanceof HTMLElement&&t.closest('[data-type="wishlist-button"]')){const e=new URL(location.href),n=e.searchParams.get("variant")&&e.searchParams.get("variant")||"";n&&(t.dataset.variantId=n),window.storecrm&&window.storecrm.render(!0)}}))}render(t,n=!1){const o=(0,e.getIcon)(this.buttonSettings,this.isFavorited),i=new URL(location.href),r=parseInt(i.searchParams.get("variant")||this.variantId||"0",10)||"",s=this.hasVariantSelector?"data-variant-selector":"",a=void 0!==this.button.dataset.noLabel;if(!this.eventTriggered)if(window.navigation)window.navigation.addEventListener("navigate",(()=>{window.setTimeout((()=>this.checkRender(t)),100)})),window.setTimeout((()=>this.checkRender(t)),100),window.setTimeout((()=>this.checkRender(t)),1e3);else{let e=location.href;window.setInterval((()=>{e!==location.href&&(e=location.href,this.checkRender(t))}),1e3),window.setTimeout((()=>this.checkRender(t)),100),window.setTimeout((()=>this.checkRender(t)),1e3)}this.eventTriggered;this.eventTriggered=!0;const c=n?"":`onclick="event.preventDefault();window.storecrm ? window.storecrm.toggleWishlist(this, ${this.isFavorited?"true":"false"}, ${this.buttonSettings.is_only_member}, '${this.buttonSettings.non_member_link}') : alert('\u8aad\u8fbc\u4e2d\u3067\u3059\u3002\u3057\u3070\u3089\u304f\u305f\u3063\u3066\u304b\u3089\u518d\u5ea6\u304a\u8a66\u3057\u304f\u3060\u3055\u3044\u3002');"`,l=``,d=document.querySelector("#storecrm-wishlistbutton-style");return n?(d&&d.remove(),document.body.insertAdjacentHTML("afterend",l)):d||document.body.insertAdjacentHTML("afterend",l),`
\n\n
`}}n.instances={};let o,i,r;e.render=({productId:t,variantId:e,id:o,variants:i,product:r,button:s,buttonSettings:a,isFavorited:c=!1,preview:l=!1,hasVariantSelector:d=!1})=>n.getInstance(o,t,i,a,s,c,d,e).render(o,l);e.hideWidgetSelector=()=>{o&&(o.remove(),o=void 0),document.querySelectorAll(".storecrm-variantselector-dropdown").forEach((t=>t.remove())),i=void 0,r=void 0};e.renderWidgetSelector=({button:t,productId:n,variants:s,wishlist:a,buttonSettings:c,preview:l=!1,rerender:d=!1})=>{const u=i===n&&r?r:s,h=o&&d&&i==n?o.style:void 0;let m=0;if(!l&&o&&d&&(m=o.scrollTop),!l&&d&&i!==n)return;if(!l&&o&&(o.remove(),o=void 0,!d))return;i=n,r=u;const p=u.map((t=>{const o=a.variants.indexOf(t.id.toString())>=0,i=(0,e.getIcon)(c,o),r=l?"":`onclick="event.preventDefault();event.stopPropagation();window.storecrm ? window.storecrm.toggleWishlist(this, ${o?"true":"false"}, ${c.is_only_member}, '${c.non_member_link}') : alert('\u8aad\u8fbc\u4e2d\u3067\u3059\u3002\u3057\u3070\u3089\u304f\u305f\u3063\u3066\u304b\u3089\u518d\u5ea6\u304a\u8a66\u3057\u304f\u3060\u3055\u3044\u3002');"`;return`\n ${i||(o?c.button_text_remove:c.button_text)}\n ${t.title}\n `})).join("");let f="";if(l)f="position: static;";else if(h)f=`top: ${h.top}; left: ${h.left};`;else{const e=t.getBoundingClientRect(),n=250;let o=e.left+document.documentElement.scrollLeft;o+n>window.innerWidth&&(o=window.innerWidth-n),f=`top: ${e.bottom+document.documentElement.scrollTop}px; left: ${o}px;`}const g=``;l||(document.body.insertAdjacentHTML("afterend",g),o=document.querySelector(".storecrm-variantselector-dropdown"),d&&m>0&&(o.scrollTop=m));{const t=t=>{t.target&&t.target instanceof HTMLElement&&t.target.closest("[data-variant-selector]")||o&&(o.remove(),o=void 0)};document.addEventListener("click",t),document.addEventListener("resize",t)}return g},e.schema={preview:(t,n)=>{let o=`
${"ja"===n?"\u304a\u6c17\u306b\u5165\u308a\u30dc\u30bf\u30f3(\u304a\u6c17\u306b\u5165\u308a\u524d)":"Favorite button (before it is added)"}
`;return o+=(0,e.render)({productId:"TEMP_product",id:"TEMP_favorite",buttonSettings:t,button:document.createElement("div"),isFavorited:!1,preview:!0,variants:[],product:null}),"variant"===t.favoriteMode&&(o+=`
${"ja"===n?"\u30d0\u30ea\u30a8\u30fc\u30b7\u30e7\u30f3\u30e2\u30fc\u30c9\u306e\u969b\u306e\u304a\u6c17\u306b\u5165\u308a\u30dc\u30bf\u30f3":"Favorite button for variant mode"}
`,o+=(0,e.renderWidgetSelector)({productId:"TEMP_product",variants:"ja"===n?[{id:"1",title:"\u30d0\u30ea\u30a8\u30fc\u30b7\u30e7\u30f31"},{id:"2",title:"\u30d0\u30ea\u30a8\u30fc\u30b7\u30e7\u30f32"},{id:"3",title:"\u30d0\u30ea\u30a8\u30fc\u30b7\u30e7\u30f33"}]:[{id:"1",title:"Variant 1"},{id:"2",title:"Variant 2"},{id:"3",title:"Variant 3"}],wishlist:{variants:[]},buttonSettings:t,button:document.createElement("div"),preview:!0,rerender:!1})),o+=`
${"ja"===n?"\u304a\u6c17\u306b\u5165\u308a\u30dc\u30bf\u30f3(\u304a\u6c17\u306b\u5165\u308a\u5f8c)":"Favorite button (after it is added)"}
`,o+=(0,e.render)({productId:"TEMP_product",id:"TEMP_favorite2",buttonSettings:t,button:document.createElement("div"),isFavorited:!0,preview:!0,variants:[],product:null}),o},rows:[{type:"card",slug:"favoriteMode",nameJa:"\u304a\u6c17\u306b\u5165\u308a\u306e\u30e2\u30fc\u30c9\u3092\u9078\u3093\u3067\u304f\u3060\u3055\u3044",nameEn:"Choose the favorite mode",default:"product",selectOptionsJa:[{value:"product",label:"\u5546\u54c1\u3054\u3068\u306b\u304a\u6c17\u306b\u5165\u308a\u3092\u3059\u308b"},{value:"variant",label:"\u30d0\u30ea\u30a8\u30fc\u30b7\u30e7\u30f3(\u5546\u54c1\u306e\u8272\u3084\u30b5\u30a4\u30ba\u306a\u3069)\u3054\u3068\u306b\u304a\u6c17\u306b\u5165\u308a\u3092\u3059\u308b"}],selectOptionsEn:[{value:"product",label:"Favorite by product"},{value:"variant",label:"Favorite by variant (such as color or size)"}],warningOnChangeJa:"\u8a2d\u5b9a\u3092\u5909\u66f4\u3059\u308b\u3068\u3001\u65e2\u5b58\u306e\u304a\u6c17\u306b\u5165\u308a\u30c7\u30fc\u30bf\u304c\u7121\u52b9\u3068\u306a\u308a\u307e\u3059\u3002\u30c7\u30fc\u30bf\u79fb\u7ba1\u3092\u3054\u5e0c\u671b\u306e\u65b9\u306f\u3053\u306e\u8a2d\u5b9a\u3092\u4fdd\u5b58\u305b\u305a\u306b\u3001\u304a\u554f\u3044\u5408\u308f\u305b\u304f\u3060\u3055\u3044\u3002",warningOnChangeEn:"Changing the setting will invalidate existing favorite data. Please contact us if you wish to transfer the data.",fullsize:!0},{type:"checkbox",slug:"is_only_member",nameJa:"\u304a\u6c17\u306b\u5165\u308a\u6a5f\u80fd\u306e\u5229\u7528\u3092\u4f1a\u54e1\u9650\u5b9a\u306b\u3059\u308b",nameEn:"Enable favorite function for sign-in customers only",default:!1,fullsize:!0},{type:"text",slug:"non_member_link",nameJa:"\u30b2\u30b9\u30c8\u304c\u304a\u6c17\u306b\u5165\u308a\u3092\u62bc\u3057\u305f\u5834\u5408\u306e\u9077\u79fb\u5148URL\u3000\u203b\u7a7a\u6b04\u306e\u5834\u5408\u30ed\u30b0\u30a4\u30f3\u753b\u9762\u306b\u9077\u79fb\u3057\u307e\u3059",nameEn:"URL to redirect to when a guest clicks the favorite button. If left blank, the login screen will be displayed.",default:"",depends:"is_only_member",fullsize:!0},{type:"select",slug:"buttonicon",nameJa:"\u30a2\u30a4\u30b3\u30f3",nameEn:"buttonIcon",selectOptionsJa:[{value:"star",label:"\u661f\u30de\u30fc\u30af(\u2606)"},{value:"heart",label:"\u30cf\u30fc\u30c8\u30de\u30fc\u30af(\u2661)"},{value:"tag",label:"\u30bf\u30b0\u30a2\u30a4\u30b3\u30f3"},{value:"clip",label:"\u30af\u30ea\u30c3\u30d7\u30a2\u30a4\u30b3\u30f3"},{value:"none",label:"\u306a\u3057"}],selectOptionsEn:[{value:"star",label:"Star icon (\u2606)"},{value:"heart",label:"Heart icon (\u2661)"},{value:"tag",label:"Tag icon"},{value:"clip",label:"Clip icon"},{value:"none",label:"None"}],default:"star"},{type:"text",slug:"button_text",nameJa:"\u30dc\u30bf\u30f3\u306e\u30c6\u30ad\u30b9\u30c8",nameEn:"buttonText",defaultJa:"\u304a\u6c17\u306b\u5165\u308a",defaultEn:"Favorite"},{type:"text",slug:"button_text_remove",nameJa:"\u30dc\u30bf\u30f3\u306e\u30c6\u30ad\u30b9\u30c8(\u304a\u6c17\u306b\u5165\u308a\u89e3\u9664)",nameEn:"buttonTextRemove",defaultJa:"\u304a\u6c17\u306b\u5165\u308a\u6e08\u307f",defaultEn:"Favorited"},{type:"checkbox",slug:"has_background",nameJa:"\u80cc\u666f\u304c\u3042\u308b\u30dc\u30bf\u30f3\u306b\u3059\u308b",nameEn:"hasBackground",default:!1},{type:"range",slug:"button_width",nameJa:"\u30dc\u30bf\u30f3\u306e\u5e45",nameEn:"buttonWidth",default:200,min:50,max:600,step:10,depends:"has_background"},{type:"range",slug:"button_height",nameJa:"\u30dc\u30bf\u30f3\u306e\u9ad8\u3055",nameEn:"buttonHeight",default:50,min:30,max:100,step:10,depends:"has_background"},{type:"colorpicker",slug:"button_color",nameJa:"\u30dc\u30bf\u30f3\u306e\u6587\u5b57\u8272",nameEn:"buttonColor",default:"#000000"},{type:"colorpicker",slug:"icon_color",nameJa:"\u30a2\u30a4\u30b3\u30f3\u306e\u6587\u5b57\u8272",nameEn:"iconColor",default:"#000000"},{type:"colorpicker",slug:"button_background_color",nameJa:"\u30dc\u30bf\u30f3\u306e\u80cc\u666f\u8272",nameEn:"buttonBackgroundColor",default:"#ffffff",depends:"has_background"},{type:"colorpicker",slug:"button_border_color",nameJa:"\u30dc\u30bf\u30f3\u306e\u7dda\u306e\u8272",nameEn:"buttonBorderColor",default:"#000000",depends:"has_background"},{type:"colorpicker",slug:"button_hover_color",nameJa:"\u30dc\u30bf\u30f3\u306e\u6587\u5b57\u8272(\u30db\u30d0\u30fc\u6642)",nameEn:"buttonHoverColor",default:"#222222"},{type:"colorpicker",slug:"icon_hover_color",nameJa:"\u30a2\u30a4\u30b3\u30f3\u306e\u6587\u5b57\u8272(\u30db\u30d0\u30fc\u6642)",nameEn:"iconHoverColor",default:"#000000"},{type:"colorpicker",slug:"button_hover_background_color",nameJa:"\u30dc\u30bf\u30f3\u306e\u80cc\u666f\u8272(\u30db\u30d0\u30fc\u6642)",nameEn:"buttonHoverBackgroundColor",default:"#dddddd",depends:"has_background"},{type:"colorpicker",slug:"button_hover_border_color",nameJa:"\u30dc\u30bf\u30f3\u306e\u7dda\u306e\u8272(\u30db\u30d0\u30fc\u6642)",nameEn:"buttonHoverBorderColor",default:"#222222",depends:"has_background"},{type:"range",slug:"button_radius",nameJa:"\u30dc\u30bf\u30f3\u306e\u4e38\u307f",nameEn:"buttonRadius",default:5,min:0,max:20,step:1,depends:"has_background"},{type:"range",slug:"button_border_width",nameJa:"\u30dc\u30bf\u30f3\u306e\u7dda\u306e\u592a\u3055",nameEn:"buttonBorderWidth",default:0,min:0,max:10,step:1,depends:"has_background"},{type:"fontpicker",slug:"button_font",nameJa:"\u30dc\u30bf\u30f3\u306e\u30d5\u30a9\u30f3\u30c8",nameEn:"buttonFont",default:"helvetica_n4"},{type:"range",slug:"button_fontsize",nameJa:"\u30dc\u30bf\u30f3\u306e\u30d5\u30a9\u30f3\u30c8\u30b5\u30a4\u30ba",nameEn:"buttonFontSize",default:16,min:10,max:30,step:1},{type:"range",slug:"button_fontweight",nameJa:"\u30dc\u30bf\u30f3\u306e\u30d5\u30a9\u30f3\u30c8\u30a6\u30a7\u30a4\u30c8",nameEn:"buttonFontWeight",default:400,min:100,max:900,step:100},{type:"range",slug:"icon_size",nameJa:"\u30a2\u30a4\u30b3\u30f3\u306e\u30b5\u30a4\u30ba",nameEn:"iconSize",default:16,min:10,max:30,step:1},{type:"range",slug:"icon_margin",nameJa:"\u30a2\u30a4\u30b3\u30f3\u3068\u30c6\u30ad\u30b9\u30c8\u3068\u306e\u9593\u9694",nameEn:"iconMargin",default:5,min:0,max:20,step:1},{type:"range",slug:"button_speed",nameJa:"\u30dc\u30bf\u30f3\u306e\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u901f\u5ea6",nameEn:"buttonSpeed",default:.3,min:0,max:1,step:.1},{type:"select",slug:"align",nameJa:"\u30dc\u30bf\u30f3\u306e\u914d\u7f6e",nameEn:"align",default:"center",selectOptionsJa:[{value:"left",label:"\u5de6\u5bc4\u305b"},{value:"center",label:"\u4e2d\u592e\u5bc4\u305b"},{value:"right",label:"\u53f3\u5bc4\u305b"}],selectOptionsEn:[{value:"left",label:"Align left"},{value:"center",label:"Align center"},{value:"right",label:"Align right"}]},{type:"colorpicker",slug:"popup_text_color",nameJa:"POPUP\u306e\u30c6\u30ad\u30b9\u30c8\u8272",nameEn:"popupTextColor",default:"#000000",checkVisible:t=>"variant"===t.favoriteMode},{type:"colorpicker",slug:"popup_background_color",nameJa:"POPUP\u306e\u80cc\u666f\u8272",nameEn:"popupBackgroundColor",default:"#ffffff",checkVisible:t=>"variant"===t.favoriteMode},{type:"colorpicker",slug:"popup_icon_color",nameJa:"POPUP\u306e\u30a2\u30a4\u30b3\u30f3\u8272",nameEn:"popupIconColor",default:"#000000",checkVisible:t=>"variant"===t.favoriteMode},{type:"colorpicker",slug:"popup_icon_hover_color",nameJa:"POPUP\u306e\u30a2\u30a4\u30b3\u30f3\u8272(\u30db\u30d0\u30fc\u6642)",nameEn:"popupIconHoverColor",default:"#000000",checkVisible:t=>"variant"===t.favoriteMode},{type:"range",slug:"popup_border_width",nameJa:"POPUP\u306e\u7dda\u306e\u592a\u3055",nameEn:"popupBorderWidth",default:0,min:0,max:10,step:1,checkVisible:t=>"variant"===t.favoriteMode},{type:"colorpicker",slug:"popup_border_color",nameJa:"POPUP\u306e\u7dda\u306e\u8272",nameEn:"popupBorderColor",default:"#999",checkVisible:t=>"variant"===t.favoriteMode}]}},158:function(t,e,n){var o=this&&this.__awaiter||function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{c(o.next(t))}catch(t){r(t)}}function a(t){try{c(o.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((o=o.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.Renderer=void 0;const i=n(215),r=n(264),s={list_title:"\u304a\u6c17\u306b\u5165\u308a\u4e00\u89a7",loading_text:"\u8aad\u8fbc\u4e2d\u3067\u3059...",non_item_text:"\u73fe\u5728\u304a\u6c17\u306b\u5165\u308a\u4e2d\u306e\u5546\u54c1\u306f\u3042\u308a\u307e\u305b\u3093",show_cart:!1,insert_cart_directly:!0};class a{static getInstance(t){return a.instance||(a.instance=new a(t)),a.instance}constructor(t){this.config=s,this.mode="product",this.inited=!1,this.parent=t}init(){return o(this,void 0,void 0,(function*(){this.inited||(this.inited=!0,yield this.loadConfig())}))}loadConfig(){return o(this,void 0,void 0,(function*(){this.config=Object.assign(Object.assign({},s),this.parent.config.favoriteList||{}),this.applyConfig(),this.mode=this.parent.favoriteMode}))}applyConfig(){const t=document.getElementById("list_title"),e=document.getElementById("loading_text"),n=document.getElementById("non_item_text");t&&(t.textContent=this.config.list_title),e&&(e.textContent=this.config.loading_text),n&&(n.textContent=this.config.non_item_text)}render(){return o(this,void 0,void 0,(function*(){var t;const e=JSON.parse(localStorage.getItem("storecrm_wishlist")||"{}");"product"===this.mode?e.products.join(","):e.variants.join(",");if(!(null==e?void 0:e.products)||0===e.products.length){null===(t=document.querySelector(".storecrm_favoritelist table"))||void 0===t||t.remove();const e=document.querySelector(".storecrm_favoritelist_loading"),n=document.querySelector(".storecrm_favoritelist_non_item");return e&&(e.style.display="none"),void(n&&(n.style.display="block"))}const n=document.querySelector(".storecrm_favoritelist_loading");n&&(n.style.display="none");const o="product"===this.mode?e.products.join(","):e.variants.join(",");yield this.loadProductAndRender(o)}))}loadProductAndRender(t){return o(this,void 0,void 0,(function*(){const e=yield fetch(`/apps/${this.parent.config.appProxyName}/favorites/products?mode=${this.mode}&ids=${t}`),n=yield e.json();this.renderProducts(n)}))}renderProducts(t){const e=document.querySelector(".storecrm_favoritelist tbody"),n=document.querySelector(".storecrm_favoritelist_loading"),o=document.querySelector(".storecrm_favoritelist table"),i=document.querySelector(".storecrm_favoritelist_non_item");if(!(e&&n&&o&&e instanceof HTMLElement&&n instanceof HTMLElement&&o instanceof HTMLElement))return;const r="variant"===this.mode?t.variants:t.products;if(!r||0===r.length)return o.style.display="none",n.style.display="none",void(i&&(i.style.display="block"));for(;e.firstChild;)e.removeChild(e.firstChild);r.forEach((t=>e.appendChild(this.createFavoriteRow(e,t)))),n.style.display="none",o.style.display="table",i&&(i.style.display="none")}createFavoriteRow(t,e){const n=document.createElement("tr");n.classList.add(`storecrm_favoritelist_id-${e.variant_id||e.product_id}`);const o="product"===this.mode?`/products/${e.handle}`:`/products/${e.handle}?variant=${e.variant_id}`,s=document.createElement("td");s.classList.add("storecrm_favoritelist_lefttd");const a=document.createElement("a");if(a.href=o,a.textContent=e.title,e.thumbnail_url){const t=document.createElement("img");t.classList.add("storecrm_favoritelist_img"),t.src=e.thumbnail_url,s.appendChild(t)}s.appendChild(a);const c=document.createElement("td");c.classList.add("storecrm_favoritelist_righttd");const l=document.createElement("div");if(l.classList.add("storecrm_favoritelist_links"),this.config.show_cart&&e.available){const t=document.createElement("a");t.classList.add("storecrm_favoritelist_link"),t.href="javascript:void(0);",t.innerHTML=r.iconCart,t.onclick=()=>(0,i.cartFavorite)(this.mode,"product"==this.mode?e.product_id:e.variant_id||"",e.handle,this.config.insert_cart_directly),l.appendChild(t)}const d=document.createElement("a");return d.classList.add("storecrm_favoritelist_link"),d.href="javascript:void(0);",d.innerHTML=r.iconDelete,"product"==this.mode||(d.dataset.variantId=e.variant_id),d.dataset.productId=e.product_id,d.onclick=()=>this.parent.toggleWishlist(d,!0,this.parent.config.favorite.is_only_member,this.parent.config.favorite.non_member_link),l.appendChild(d),c.appendChild(l),n.appendChild(s),n.appendChild(c),n}}e.Renderer=a,a.instance=void 0},264:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.iconCart=e.iconDelete=void 0,e.iconDelete='',e.iconCart=''},215:function(t,e){var n=this&&this.__awaiter||function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{c(o.next(t))}catch(t){r(t)}}function a(t){try{c(o.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((o=o.apply(t,e||[])).next())}))};function o(t){return n(this,void 0,void 0,(function*(){try{const e=yield fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,quantity:1})});if(!e.ok)throw new Error(`Failed to add to cart: ${e.statusText}`);const n=yield e.json();console.log("StoreCRM: \u5546\u54c1\u304c\u30ab\u30fc\u30c8\u306b\u8ffd\u52a0\u3055\u308c\u307e\u3057\u305f:",n),window.location.href="/cart"}catch(t){console.error("StoreCRM: \u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f:",t),alert("\u30ab\u30fc\u30c8\u306b\u8ffd\u52a0\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002")}}))}Object.defineProperty(e,"__esModule",{value:!0}),e.addToCart=e.cartFavorite=void 0,e.cartFavorite=function(t,e,n,i){"product"!==t?i?o(e):window.location.href=`/products/${encodeURIComponent(n)}?variant=${e}`:window.location.href=`/products/${encodeURIComponent(n)}`},e.addToCart=o},700:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});class n{constructor(t){this.loginButtonImg="/buttons/images/line_login_btn.png",this.parent=t}static isLoginOrRegisterPage(){const t=window.location.pathname,e=n.isLoginPath(t),o=n.isRegisterPath(t);if(e||o)return!0;const i=n.isLoginPage(),r=n.isRegisterPage();return!(!i&&!r)}static isLineLoginEnabled(){return window.storecrm_config.line&&window.storecrm_config.line.line_login_enable?!(window.storecrm_config.line.line_login_onlypreview&&!(window.Shopify&&window.Shopify.designMode||document.querySelector("#OnlineStorePreviewBarNextData")))||(console.info("StoreCRM: line_login_onlypreview is set, but not in Shopify designMode. LINE login will not be initialized."),!1):(console.info("StoreCRM: line_login_enable is not set or false. LINE login will not be initialized."),!1)}init(){if(n.isLineLoginEnabled())try{const t=document.querySelectorAll(`.${n.CUSTOM_CONTAINER_CLASS}`);if(t.length>0)return void t.forEach((t=>{const e=this.createLineButton(!0);t.appendChild(e)}));n.isLoginPage()&&this.addLoginButton(),n.isRegisterPage()&&this.addRegisterButton(),this.clearSessionStorage()}catch(t){console.error("Error in init:",t)}}clearSessionStorage(){location.pathname.includes("/register")||(sessionStorage.removeItem("line_email"),sessionStorage.removeItem("line_lineId"))}static isLoginPage(){try{return!!document.querySelector('form[action*="login"], form[action*="sign_in"]')}catch(t){return console.error("Error in isLoginPage:",t),!1}}static isRegisterPage(){try{return!!document.querySelector('form[action^="/account"]')}catch(t){return console.error("Error in isRegisterPage:",t),!1}}addLoginButton(){var t;const e=document.querySelector('form[action*="/account/login"]');if(!e)return;let n=e.querySelector('button[type="submit"]');if(n||(n=e.querySelector("button")),!n){const t=document.createElement("div");t.className="line-login-container",t.style.marginTop="20px",t.style.textAlign="center";const n=this.createLineButton(!0);return t.appendChild(n),void e.appendChild(t)}const o=document.createElement("div");o.className="line-login-container",o.style.marginTop="20px",o.style.textAlign="center";const i=this.createLineButton(!0);o.appendChild(i),null===(t=n.parentNode)||void 0===t||t.insertBefore(o,n.nextSibling)}addRegisterButton(){var t;const e=document.querySelector('form[action^="/account"]');if(!e)return;const n=new URLSearchParams(window.location.search);let o=n.get("email"),i=n.get("line_id");if(o?sessionStorage.setItem("line_email",o):o=sessionStorage.getItem("line_email"),i?sessionStorage.setItem("line_lineId",i):i=sessionStorage.getItem("line_lineId"),o&&o.includes("@")){const t=e.querySelector('input[name="customer[email]"]');t&&(t.value=o)}if(i){let t=e.querySelector('input[name="customer[note][lineId]"]');t||(t=document.createElement("input"),t.type="hidden",t.name="customer[note][lineId]",e.appendChild(t)),t.value=i}if(i||o)try{const t=e,n=new URL(t.action,window.location.origin);i?n.searchParams.set("line_id",i):n.searchParams.delete("line_id"),o?n.searchParams.set("email",o):n.searchParams.delete("email"),t.action=n.pathname+(n.search?n.search:"")}catch(t){console.error("Failed to update form action with line_id/email:",t)}if(i){const t=document.createElement("div");return t.textContent="LINE\u30ed\u30b0\u30a4\u30f3\u3092\u884c\u3044\u307e\u3057\u305f\u3002\u9023\u643a\u3092\u884c\u3063\u3066\u4f1a\u54e1\u767b\u9332\u3092\u884c\u3046\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u30d5\u30a9\u30fc\u30e0\u3088\u308a\u3054\u767b\u9332\u304f\u3060\u3055\u3044",t.style.color="#d32f2f",t.style.fontWeight="bold",t.style.fontSize="13px",t.style.marginBottom="20px",t.style.textAlign="center",void e.insertBefore(t,e.firstChild)}let r=e.querySelector('button[type="submit"]');if(r||(r=e.querySelector("button")),!r){const t=document.createElement("div");t.className="line-login-container",t.style.marginTop="20px",t.style.textAlign="center";const n=this.createLineButton(!1);return t.appendChild(n),void e.appendChild(t)}const s=document.createElement("div");s.className="line-login-container",s.style.marginTop="20px",s.style.textAlign="center";const a=this.createLineButton(!1);s.appendChild(a),null===(t=r.parentNode)||void 0===t||t.insertBefore(s,r.nextSibling)}createLineButton(t=!0){if(!document.getElementById("btn-line-login-style")){const t=document.createElement("style");t.id="btn-line-login-style",t.innerHTML=".btn-line-login::after { box-shadow: none !important; }",document.head.appendChild(t)}const e=document.createElement("button");e.type="button",e.className="btn-line-login",e.style.backgroundColor="#06C755",e.style.color="#FFFFFF",e.style.border="none",e.style.borderRadius="4px",e.style.padding="0 6px",e.style.cursor="pointer",e.style.display="flex",e.style.alignItems="center",e.style.justifyContent="center",e.style.width="auto",e.style.height="48px",e.style.marginBottom="10px",e.style.textAlign="center",e.style.fontWeight="bold",e.style.fontSize="16px",e.style.letterSpacing="0.03em",e.style.boxShadow="0 2px 4px 0 rgba(0,0,0,0.04)",e.style.transition="background 0.2s",e.style.position="relative",e.style.overflow="hidden",e.style.boxSizing="border-box",e.style.marginTop="12px",e.style.marginBottom="12px",e.style.paddingTop="0",e.style.paddingBottom="0",e.onmouseover=()=>{e.style.backgroundColor="#06C755",e.style.filter="brightness(0.95)"},e.onmouseout=()=>{e.style.backgroundColor="#06C755",e.style.filter="none"},e.onmousedown=()=>{e.style.backgroundColor="#06C755",e.style.filter="brightness(0.85)"},e.onmouseup=()=>{e.style.backgroundColor="#06C755",e.style.filter="brightness(0.95)"};const o=document.createElement("span");o.style.display="flex",o.style.alignItems="center",o.style.justifyContent="center",o.style.marginRight="12px",o.style.width="32px",o.style.height="32px",o.style.flexShrink="0",o.style.background="none";const i=document.createElement("img");i.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAsCAYAAAAehFoBAAACpUlEQVRYhe2XTYhNURzAf8cMZSQSRT4LSRaGfISNlLJ8WUiUUMrKRoqFlUyyQNnY2tnaaEI2vmZKeoo0YUE+UhYTEoN+FveOnjvn3ufNu++N9H6re+85//P/nf875577oEOHDh3+K0IzwWo3sAXYDqwDlgMLgClplxHgNfAMeADcBO6EEH40k3c8ovPUs+p7G+d9GjuvHaLT1DPqt3GIZhlJx5rWKtledagE0SxDam/ZstvUTy2QHeWTuq0s2c3qlxbKjvJF3VzPp/Atoc4GqsD8UmZfnzdAbwjhQ16HSXUG6KN9sqS5+oo65FZYXQy8ALpKlqrHT2BpCOFlrLG7IHAfY2WHgGFgY+b5C+AtsAl4BbwjOVBGeUJyiKwC7mdie4D1Nfddae5TBW5jUe9GNsbWtC1LJX1eVfen1xdq2teoS9RqJM/MyHh387yKKryqoRmO5RiwgaTqZiQrQCW9jR0cubmLNt2MBgWzTAV2AbEd/5VkaQ0DHxvJXVThZrkM7AT2kGyk34QQ+oF+SJYEcPBvBy2qcHSXNkAFOBpCuAE8rm1QD6frvQoMRGJf5Q1aVOFBYHFO24Ga66LqnFEHQwi39Y9lPECyLABmAuczcfcKxoyj7o7s3h2RfpfSvkF9qh5Su2ti3qpz1eXq40j8nEienXleRQfHFOA5sLDh2TbHc2Bl3kd+7hoOIYwAx1tlVcCRpv6RqFciP1mruNj0dNUe46de2VxXJzctnEpPV6+1UPaW2lOKbI30JPWE+rVk2auly2bEl5ms658lyJ5T2/P5qi5ST6qPxiH6Wd3dFtEc+VnqdvW4+qyO7EN1xYTJZlHX5Yh+V0+bHEj/DuraiOwDdfVEu0VR99aIDqtHbdfGGg8mn46fTd4Asyfap0OHDh3+cX4BcUOZ2CqT2BUAAAAASUVORK5CYII=",i.width=32,i.height=32,i.alt="LINE",i.style.display="block",i.style.width="32px",i.style.height="32px",o.appendChild(i);const r=document.createElement("span");r.textContent=t?n.BUTTON_TEXT:n.REGISTER_BUTTON_TEXT,r.style.display="inline-block",r.style.whiteSpace="nowrap",r.style.fontWeight="bold",r.style.fontSize="16px",r.style.lineHeight="1",r.style.letterSpacing="0.03em",r.style.userSelect="none",r.style.padding="0 32px",e.appendChild(o),e.appendChild(r);const s=document.createElement("div");s.className="line-login-container",s.style.display="flex",s.style.justifyContent="center",s.style.alignItems="center",s.style.width="100%",s.style.marginTop="20px",s.style.marginBottom="10px",s.appendChild(e),e.onclick=()=>{this.parent.doLineLogin()};const a=new URLSearchParams(window.location.search).get("line_login_error"),c=document.createElement("div");if(c.style.display="flex",c.style.flexDirection="column",c.style.alignItems="center",c.style.width="100%",c.appendChild(s),a){const t=document.createElement("div");t.textContent=a,t.style.color="#d32f2f",t.style.fontWeight="bold",t.style.fontSize="13px",t.style.marginTop="0px",t.style.marginBottom="15px",t.style.textAlign="center",c.appendChild(t)}return c}static isLoginPath(t){return"/account/login"===t||/\blogin\b/i.test(t)}static isRegisterPath(t){return"/account/register"===t||(/\bregister\b/i.test(t)||/\bsignup\b/i.test(t))}}n.BUTTON_CLASS="line-login-button",n.CUSTOM_CONTAINER_CLASS="line-login-custom-container",n.instance=null,n.BUTTON_TEXT="LINE\u3067\u30ed\u30b0\u30a4\u30f3",n.REGISTER_BUTTON_TEXT="LINE\u3067\u767b\u9332",e.default=n},209:function(t,e,n){var o=this&&this.__awaiter||function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{c(o.next(t))}catch(t){r(t)}}function a(t){try{c(o.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((o=o.apply(t,e||[])).next())}))},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.schema=e.LineRestockPopupManager=void 0;const r=i(n(804));class s{constructor(t,e=!1){this.preview=!1,this.inited=!1,this.container=null,this.title=null,this.content=null,this.footer=null,this.button=null,this.lineLoginButton=null,this.close=null,this.product_id=null,this.line_profile=null,this.preview=e,this.config=t,this.init()}static getInstance(t,e=!1){return s.instance?(s.instance.config=t,s.instance.preview=e):s.instance=new s(t,e),s.instance}setParent(t){this.parent=t}renderTemplate(){document&&document.body?document.body.insertAdjacentHTML("beforeend",s.template):window.setTimeout(this.renderTemplate.bind(this),100)}init(){document&&document.body?this.runInit():window.setTimeout(this.init.bind(this),100)}runInit(){this.inited=!0,this.preview||document.body.insertAdjacentHTML("beforeend",s.template),r.default.init(),this.updateElements(),this.container&&this.container.addEventListener("click",(t=>{t.stopPropagation()})),this.close&&!this.preview&&this.close.addEventListener("click",(t=>{r.default.close("storecrm-line-restock-modal")}))}updateElements(){this.container=document.getElementById("storecrm-line-restock-modal"),this.title=document.getElementById("storecrm-line-restock-title"),this.content=document.getElementById("storecrm-line-restock-content"),this.footer=document.getElementById("storecrm-line-restock-footer"),this.close=document.getElementById("storecrm-line-restock-close")}getLineProfileFromURL(){console.log("StoreCRM: getLineProfileFromURL called");try{const t=new URLSearchParams(window.location.search).get("line_profile_data");if(t){const e=atob(t),n=JSON.parse(e),o={display_name:n.displayName||"",picture_url:n.pictureUrl||"",line_customer_id:n.userId||""};window.sessionStorage.setItem("storecrm_line_profile",JSON.stringify(o));const i=new URL(window.location.href);return i.searchParams.delete("line_profile_data"),window.history.replaceState({},"",i.toString()),o}}catch(t){console.error("StoreCRM: Failed to parse line profile from URL",t)}}getLineProfileFromSessionStorage(){try{const t=window.sessionStorage.getItem("storecrm_line_profile");if(t)return JSON.parse(t)}catch(t){console.error("StoreCRM: Failed to parse line profile from session storage",t)}}render(t,e,n){this.preview&&this.updateElements();let o=!1;if(n||this.preview||((n=this.getLineProfileFromURL())?o=!0:n=this.getLineProfileFromSessionStorage()),n&&!this.preview&&(null!=n.display_name&&null!=n.picture_url&&null!=n.line_customer_id||(n=void 0,window.sessionStorage.removeItem("storecrm_line_profile"))),!this.title||!this.content||!this.footer)return;const i=document.createElement("button");i.className="storecrm_modal__btn storecrm_modal__btn-primary",i.innerHTML=t.button_text||"\u518d\u5165\u8377\u901a\u77e5\u3092\u6709\u52b9\u306b\u3059\u308b";const r=document.createElement("button");r.className="storecrm_modal__btn storecrm_modal__btn-primary storecrm_modal__btn-line-login",r.innerHTML="LINE\u9023\u643a\u3092\u884c\u3046",n||this.preview||(i.style.display="none",r.style.display="block"),n&&!this.preview&&(r.style.display="none",i.style.display="block"),0!==this.footer.children.length&&(this.footer.innerHTML=""),this.footer.appendChild(i),this.footer.appendChild(r),this.button=i,this.lineLoginButton=r,this.button&&!this.preview&&(this.button.addEventListener("click",(()=>{this.handleEnableClick()})),this.lineLoginButton.addEventListener("click",(()=>{this.handleLineSubscribeClick()}))),this.config=t,this.title.innerText=t.title||"LINE\u518d\u5165\u8377\u901a\u77e5";let s=`\n
${t.description_text||"\u3053\u306e\u5546\u54c1\u306e\u518d\u5165\u8377\u3092LINE\u3067\u304a\u77e5\u3089\u305b\u3057\u307e\u3059"}
\n
\n `,a=null;if(location.search&&location.search.includes("variant")){const t=new URL(location.href);a=t.searchParams.get("variant")}const c=e.filter((t=>!t.available)).map((t=>``)).join("");if(e&&Array.isArray(e)&&e.length>1?(s=s.replace("\x3c!-- select_style --\x3e",""),s=s.replace("\x3c!-- options --\x3e",c)):(s=s.replace("\x3c!-- select_style --\x3e","display:none"),s=s.replace("\x3c!-- options --\x3e",c)),(n||this.preview)&&(this.line_profile=n||{display_name:"LINE\u9867\u5ba2\u540d",picture_url:"https://placehold.co/60x60?text=LINE&font=roboto",line_customer_id:"preview-user"},s+=`\n
\n avatar\n
${this.line_profile.display_name}
\n
`),s+='
',this.content.innerHTML=s,this.content.style.color=t.text_color||"#000000",this.container){const e=this.container.querySelector(".storecrm_modal__container");e&&(e.style.backgroundColor=t.background_color||"#ffffff",e.style.borderRadius=`${t.popup_radius||10}px`)}this.button&&(this.button.style.backgroundColor=t.button_background_color||"#222222",this.button.style.color=t.button_text_color||"#dddddd",this.button.style.borderRadius="4px"),this.lineLoginButton&&(this.lineLoginButton.style.backgroundColor="#06C755",this.lineLoginButton.style.color="#ffffff",this.lineLoginButton.style.borderRadius="4px"),this.close&&(this.close.style.color=t.close_text_color||"#000000"),this.resetMessage(),this.preview&&(this.success(t.success_text||"\u518d\u5165\u8377\u901a\u77e5\u304c\u767b\u9332\u3055\u308c\u307e\u3057\u305f\uff01"),this.failure(t.error_text||"\u518d\u5165\u8377\u901a\u77e5\u306e\u767b\u9332\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002"),this.container&&this.container.querySelectorAll(".storecrm_modal__overlay,.storecrm_modal__close").forEach((t=>{t.addEventListener("click",(t=>{t.preventDefault(),t.stopPropagation()}))})))}handleEnableClick(){return o(this,void 0,void 0,(function*(){var t,e,n;if(this.preview)return;this.resetMessage(),this.disableButton();const o=null===(t=this.content)||void 0===t?void 0:t.querySelector("#storecrm_restock_variant"),i=o?o.value:"";this.parent&&this.parent.storeLineRestock(this.product_id,i,null===(e=this.line_profile)||void 0===e?void 0:e.line_customer_id,null===(n=this.line_profile)||void 0===n?void 0:n.display_name,JSON.stringify(this.line_profile),this.success.bind(this),this.failure.bind(this))}))}handleLineSubscribeClick(){return o(this,void 0,void 0,(function*(){this.preview||(this.resetMessage(),this.disableButton(),console.log("StoreCRM: LINE\u8cfc\u8aad\u51e6\u7406\u3092\u3057\u307e\u3059"),this.parent&&this.parent.lineSubscribe((function(t){alert(t)})))}))}resetMessage(){this.footer&&this.footer.querySelectorAll(".storecrm_modal_message").forEach((t=>t.remove()))}disableButton(){this.button&&(this.button.setAttribute("disabled","disabled"),this.button.innerText="\u9001\u4fe1\u4e2d...")}enableButton(){this.button&&(this.button.removeAttribute("disabled"),this.button.innerText=this.config.button_text||"\u518d\u5165\u8377\u901a\u77e5\u3092\u6709\u52b9\u306b\u3059\u308b")}success(t){this.enableButton();const e=document.createElement("div");e.classList.add("storecrm_modal_success","storecrm_modal_message"),e.style.color=this.config.success_text_color||"#166534",e.style.backgroundColor=this.config.success_background_color||"#F0FDF4",e.style.padding="1rem",e.style.marginTop="1rem",e.style.borderRadius="4px",e.innerText=t,this.footer&&this.footer.appendChild(e)}failure(t){this.enableButton();const e=document.createElement("div");e.classList.add("storecrm_modal_error","storecrm_modal_message"),e.style.color=this.config.error_text_color||"#991B1B",e.style.backgroundColor=this.config.error_background_color||"#FEF2F2",e.style.padding="1rem",e.style.marginTop="1rem",e.style.borderRadius="4px",e.innerText=t,this.footer&&this.footer.appendChild(e)}show(t,e,n,o){this.product_id=n,this.inited?this.runShow(t,e,o):window.setTimeout((()=>this.show(t,e,n,o)),100)}runShow(t,e,n){this.render(t,e,n),r.default.show("storecrm-line-restock-modal",{disableFocus:!0})}hide(){r.default.close("storecrm-line-restock-modal")}}e.LineRestockPopupManager=s,s.template='';let a=null;e.schema={preview:(t,e)=>{var n,o;return n=()=>{s.getInstance(t,!0).show(t,[],"1234567890",void 0)},o=300,clearTimeout(a),a=setTimeout(n,o),s.template},rows:[{type:"text",slug:"title",nameJa:"\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u306e\u30bf\u30a4\u30c8\u30eb",nameEn:"Popup title",defaultJa:"LINE\u518d\u5165\u8377\u901a\u77e5",defaultEn:"LINE Restock Notification"},{type:"text",slug:"description_text",nameJa:"\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u306e\u672c\u6587",nameEn:"Popup description",defaultJa:"\u3053\u306e\u5546\u54c1\u306e\u518d\u5165\u8377\u3092LINE\u3067\u304a\u77e5\u3089\u305b\u3057\u307e\u3059",defaultEn:"We will notify you via LINE when this product is restocked."},{type:"colorpicker",slug:"background_color",nameJa:"\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u306e\u80cc\u666f\u8272",nameEn:"Popup background color",default:"#ffffff"},{type:"colorpicker",slug:"text_color",nameJa:"\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u306e\u30c6\u30ad\u30b9\u30c8\u8272",nameEn:"Text color",default:"#000000"},{type:"colorpicker",slug:"close_text_color",nameJa:"\u9589\u3058\u308b\u30dc\u30bf\u30f3\u306e\u8272",nameEn:"Popup close button text color",default:"#000000"},{type:"colorpicker",slug:"button_background_color",nameJa:"\u30dc\u30bf\u30f3\u306e\u80cc\u666f\u8272",nameEn:"Button background color",default:"#222222"},{type:"colorpicker",slug:"button_text_color",nameJa:"\u30dc\u30bf\u30f3\u306e\u30c6\u30ad\u30b9\u30c8\u30ab\u30e9\u30fc",nameEn:"Button text color",default:"#dddddd"},{type:"text",slug:"button_text",nameJa:"\u30dc\u30bf\u30f3\u306e\u30c6\u30ad\u30b9\u30c8",nameEn:"Button text",defaultJa:"\u518d\u5165\u8377\u901a\u77e5\u3092\u6709\u52b9\u306b\u3059\u308b",defaultEn:"Enable restock notification"},{type:"text",slug:"success_text",nameJa:"\u6210\u529f\u6642\u306e\u30c6\u30ad\u30b9\u30c8",nameEn:"Success text",defaultJa:"\u518d\u5165\u8377\u901a\u77e5\u304c\u767b\u9332\u3055\u308c\u307e\u3057\u305f\uff01",defaultEn:"Restock notification registered!"},{type:"colorpicker",slug:"success_background_color",nameJa:"\u6210\u529f\u6642\u306e\u80cc\u666f\u8272",nameEn:"Success background color",default:"#F0FDF4"},{type:"colorpicker",slug:"success_text_color",nameJa:"\u6210\u529f\u6642\u306e\u6587\u5b57\u8272",nameEn:"Success text color",default:"#166534"},{type:"text",slug:"error_text",nameJa:"\u5931\u6557\u6642\u306e\u30c6\u30ad\u30b9\u30c8",nameEn:"Error text",defaultJa:"\u518d\u5165\u8377\u901a\u77e5\u306e\u767b\u9332\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002\u3057\u3070\u3089\u304f\u305f\u3063\u3066\u304b\u3089\u518d\u5ea6\u304a\u8a66\u3057\u304f\u3060\u3055\u3044\u3002",defaultEn:"Failed to register restock notification. Please try again later."},{type:"colorpicker",slug:"error_background_color",nameJa:"\u30a8\u30e9\u30fc\u6642\u306e\u80cc\u666f\u8272",nameEn:"Error background color",default:"#FEF2F2"},{type:"colorpicker",slug:"error_text_color",nameJa:"\u30a8\u30e9\u30fc\u6642\u306e\u6587\u5b57\u8272",nameEn:"Error text color",default:"#991B1B"},{type:"range",slug:"popup_radius",nameJa:"\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u306e\u4e38\u307f",nameEn:"Popup border radius",default:10,min:0,max:20,step:1}]}},392:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.schema=e.render=e.generateDefaultSettings=e.LineRestockButton=void 0;class n{constructor(t,e,n,o,i){this.eventTriggered=!1,this.variants=n,this.buttonSettings=o,this.productId=e,this.product=i}static getInstance(t,e=null,o=null,i=null,r=null){if(n.instances[t])i&&(n.instances[t].buttonSettings=i);else{if(!(e&&o&&i&&r))throw new Error("StoreCRM LineRestock: productId, variants, buttonSettings, product are required");n.instances[t]=new n(t,e,o,i,r)}return n.instances[t]}createScript(t,e){const n=t?"onclick=\"event.preventDefault();(function(){ const el=document.getElementById('storecrm-line-restock-modal'); if(el){ el.style.display='flex'; } })();\"":`onclick="event.preventDefault();window.storecrm ? window.storecrm.showLineRestockPopup('${e}') : alert('\u8aad\u8fbc\u4e2d\u3067\u3059\u3002\u3057\u3070\u3089\u304f\u305f\u3063\u3066\u304b\u3089\u518d\u5ea6\u304a\u8a66\u3057\u304f\u3060\u3055\u3044\u3002');"`;return`\n\n\n
\n\n
\n `}checkRender(t){document.querySelectorAll(`.storecrm-line-restock-${t}`).forEach((e=>{var n,o;if(e instanceof HTMLElement&&e.closest('[data-type="line-restock-button"]')){const i=new URL(location.href),r=(null===(n=this.variants.find((t=>t.available)))||void 0===n?void 0:n.id)||this.variants[0].id||null,s=parseInt(i.searchParams.get("variant")||r,10);if(!s)return void console.error("StoreCRM Restock: variantId is not set",s);if(!this.product||!this.product.tags||this.product.tags.indexOf("storecrm-restock-hidden")>=0)return void(e.style.display="none");const a=window.Shopify&&window.Shopify.designMode||this.variants.find((t=>!t.available&&t.id===s));e.style.display=a?"inline-block":"none";const c=new URLSearchParams(window.location.search),l=(c.get("line_profile_data"),c.get("line_login_error"));if(l)return void console.error("LINE\u30ed\u30b0\u30a4\u30f3\u95a2\u9023\u306e\u30a8\u30e9\u30fc:",l);if(c.get("line_connect"))return void(null===(o=window.storecrm)||void 0===o||o.showLineRestockPopup(t))}}))}render(t,e=!1){if(e)return this.createScript(!0,t);if(!this.eventTriggered){if(this.eventTriggered=!0,window.navigation)window.navigation.addEventListener("navigate",(()=>{window.setTimeout((()=>this.checkRender(t)),100)})),window.setTimeout((()=>this.checkRender(t)),100),window.setTimeout((()=>this.checkRender(t)),1e3);else{let e=location.href;window.setInterval((()=>{e!==location.href&&(e=location.href,this.checkRender(t))}),1e3),window.setTimeout((()=>this.checkRender(t)),100),window.setTimeout((()=>this.checkRender(t)),1e3)}return this.createScript(!1,t)}}}e.LineRestockButton=n,n.instances={};e.generateDefaultSettings=(t="ja")=>{const n={};return e.schema.rows.forEach((e=>{"text"===e.type?n[e.slug]="ja"===t?e.defaultJa:e.defaultEn:(e.type,n[e.slug]=e.default)})),n};e.render=({productId:t,variantId:e,variants:o,id:i,buttonSettings:r,isOutOfStock:s,product:a,preview:c=!1})=>n.getInstance(i,t,o,r,a).render(i,c),e.schema={preview:(t,n)=>(0,e.render)({productId:"TEMP_productId",id:"TEMP_line_restock",buttonSettings:t,isOutOfStock:!1,preview:!0,product:{tags:[]},variants:[]}),info:{textJa:"\u30ef\u30f3\u30b9\u30c6\u30c3\u30d7\u3067\u518d\u5165\u8377\u901a\u77e5\u3092LINE\u3067\u53d7\u3051\u53d6\u308c\u308b\u30dc\u30bf\u30f3\u3092\u8a2d\u7f6e\u3057\u307e\u3059\u3002",textEn:"Set up a button that allows customers to receive restock notifications via LINE in one step.",noteJa:'\u203b\u672c\u6a5f\u80fd\u3092\u6709\u52b9\u306b\u3059\u308b\u306b\u306fLINE\u9023\u643a\u8a2d\u5b9a\u304c\u5b8c\u4e86\u3057\u3066\u3044\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002',noteEn:'\u203bLINE integration settings must be completed to enable this feature.'},rows:[{type:"text",slug:"button_text",nameJa:"\u30dc\u30bf\u30f3\u306e\u30c6\u30ad\u30b9\u30c8",nameEn:"buttonText",defaultJa:"LINE\u3067\u518d\u5165\u8377\u901a\u77e5\u3092\u53d7\u3051\u53d6\u308b",defaultEn:"Get LINE restock notifications"},{type:"range",slug:"button_width",nameJa:"\u30dc\u30bf\u30f3\u306e\u5e45",nameEn:"buttonWidth",default:240,min:50,max:600,step:10},{type:"range",slug:"button_height",nameJa:"\u30dc\u30bf\u30f3\u306e\u9ad8\u3055",nameEn:"buttonHeight",default:50,min:30,max:100,step:5},{type:"colorpicker",slug:"button_color",nameJa:"\u30dc\u30bf\u30f3\u306e\u6587\u5b57\u8272",nameEn:"buttonColor",default:"#000000"},{type:"colorpicker",slug:"button_background_color",nameJa:"\u30dc\u30bf\u30f3\u306e\u80cc\u666f\u8272",nameEn:"buttonBackgroundColor",default:"#ffffff"},{type:"colorpicker",slug:"button_border_color",nameJa:"\u30dc\u30bf\u30f3\u306e\u7dda\u306e\u8272",nameEn:"buttonBorderColor",default:"#000000"},{type:"colorpicker",slug:"button_hover_color",nameJa:"\u30dc\u30bf\u30f3\u306e\u6587\u5b57\u8272(\u30db\u30d0\u30fc\u6642)",nameEn:"buttonHoverColor",default:"#222222"},{type:"colorpicker",slug:"button_hover_background_color",nameJa:"\u30dc\u30bf\u30f3\u306e\u80cc\u666f\u8272(\u30db\u30d0\u30fc\u6642)",nameEn:"buttonHoverBackgroundColor",default:"#dddddd"},{type:"colorpicker",slug:"button_hover_border_color",nameJa:"\u30dc\u30bf\u30f3\u306e\u7dda\u306e\u8272(\u30db\u30d0\u30fc\u6642)",nameEn:"buttonHoverBorderColor",default:"#222222"},{type:"range",slug:"button_radius",nameJa:"\u30dc\u30bf\u30f3\u306e\u4e38\u307f",nameEn:"buttonRadius",default:0,min:0,max:20,step:1},{type:"range",slug:"button_border_width",nameJa:"\u30dc\u30bf\u30f3\u306e\u7dda\u306e\u592a\u3055",nameEn:"buttonBorderWidth",default:0,min:0,max:5,step:1},{type:"fontpicker",slug:"button_font",nameJa:"\u30dc\u30bf\u30f3\u306e\u30d5\u30a9\u30f3\u30c8",nameEn:"buttonFont",default:"helvetica_n4"},{type:"range",slug:"button_fontsize",nameJa:"\u30dc\u30bf\u30f3\u306e\u30d5\u30a9\u30f3\u30c8\u30b5\u30a4\u30ba",nameEn:"buttonFontSize",default:16,min:10,max:30,step:1},{type:"range",slug:"button_fontweight",nameJa:"\u30dc\u30bf\u30f3\u306e\u30d5\u30a9\u30f3\u30c8\u30a6\u30a7\u30a4\u30c8",nameEn:"buttonFontWeight",default:400,min:100,max:900,step:100},{type:"range",slug:"button_speed",nameJa:"\u30dc\u30bf\u30f3\u306e\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u901f\u5ea6",nameEn:"buttonSpeed",default:.3,min:0,max:1,step:.1},{type:"select",slug:"align",nameJa:"\u30dc\u30bf\u30f3\u306e\u914d\u7f6e",nameEn:"align",default:"center",defaultJa:"\u4e2d\u592e\u5bc4\u305b",defaultEn:"Center",selectOptionsJa:[{value:"left",label:"\u5de6\u5bc4\u305b"},{value:"center",label:"\u4e2d\u592e\u5bc4\u305b"},{value:"right",label:"\u53f3\u5bc4\u305b"}],selectOptionsEn:[{value:"left",label:"Align left"},{value:"center",label:"Align center"},{value:"right",label:"Align right"}]}]}},435:function(t,e,n){var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.schema=e.RestockPopupManager=void 0;const i=o(n(804));class r{constructor(t,e=!1){this.content=null,this.title=null,this.secondTitle=null,this.popup=null,this.button=null,this.footer=null,this.secondFooter=null,this.preview=!1,this.showSecondPopup=!1,this.container=null,this.secondContainer=null,this.secondContent=null,this.close=null,this.product_id=null,this.inited=!1,this.preview=e,this.config=t,this.init()}static getInstance(t,e=!1){return r.instance?(r.instance.config=t,r.instance.preview=e):r.instance=new r(t,e),r.instance}setParent(t){this.parent=t}renderTemplate(){document&&document.body?document.body.insertAdjacentHTML("beforeend",r.template):window.setTimeout(this.renderTemplate.bind(this),100)}init(){document&&document.body?this.runInit():window.setTimeout(this.init.bind(this),100)}runInit(){this.inited=!0,this.preview||document.body.insertAdjacentHTML("beforeend",r.template),i.default.init(),this.updateElements(),this.container&&this.container.addEventListener("click",(t=>{t.stopPropagation()})),this.close=this.container&&this.container.querySelectorAll(".storecrm_modal__close"),this.close&&!this.preview&&this.close.forEach((t=>{t.addEventListener("click",(t=>{i.default.close("storecrm-modal")}))}))}updateElements(){this.popup=document.getElementById("storecrm-modal"),this.content=document.getElementById("storecrm-modal-content"),this.secondContent=document.getElementById("storecrm-modal-second-content"),this.title=document.getElementById("storecrm-modal-title"),this.secondTitle=document.getElementById("storecrm-modal-second-title"),this.footer=document.querySelector(".storecrm_modal__footer"),this.secondFooter=document.getElementById("storecrm-modal-second-footer"),this.container=document.querySelector(".storecrm_modal__container"),this.secondContainer=document.getElementById("storecrm-modal-second-popup-preview")}render(t,e){var n,o,i,r;this.preview&&this.updateElements(),this.showSecondPopup=t.add_accepts_marketing_checkbox&&this.preview;const s=document.createElement("button");s.className="storecrm_modal__btn storecrm_modal__btn-primary",s.innerHTML=t.button_text,this.footer&&0!==this.footer.children.length&&(this.footer.innerHTML=""),null===(n=this.footer)||void 0===n||n.appendChild(s),this.button=s,this.button&&!this.preview&&this.button.addEventListener("click",(()=>{this.checkAcceptsMarketingStatusAndClearMessages()})),this.config=t;const a=(null===(o=window.storecrm_data)||void 0===o?void 0:o.customer_email)||window.localStorage.getItem("storecrm_restock_email")||"";if(this.title&&this.content&&this.popup){this.title.innerText=t.popup_title;let n=`\n
${t.popup_description}
\n
\n
${t.emailaddress}
\n${t.add_accepts_marketing_checkbox?``:""}\n${t.add_accepts_marketing_checkbox?``:""}\n
\n`.trim(),o=null;if(location.search&&location.search.includes("variant")){const t=new URL(location.href);o=t.searchParams.get("variant")}console.error("RestockPopupManager: render: variants",e,o);const i=e.filter((t=>!t.available)).map((t=>``)).join("");e&&Array.isArray(e)&&e.length>1?(n=n.replace("\x3c!-- select_style --\x3e",""),n=n.replace("\x3c!-- options --\x3e",i)):(n=n.replace("\x3c!-- select_style --\x3e","display:none"),n=n.replace("\x3c!-- options --\x3e",i)),this.content.innerHTML=n,this.content.style.color=t.text_color,this.container&&(this.container.style.backgroundColor=t.background_color,this.container.style.borderRadius=`${t.button_radius}px`,this.container.style.width="100%"),this.button&&(this.button.style.backgroundColor=t.button_background_color,this.button.style.color=t.button_text_color),this.close&&this.close.forEach((e=>{e.style.color=t.close_text_color}))}if(this.resetMessage(),this.showSecondPopup&&this.secondTitle&&this.secondContent&&this.secondContainer){this.secondContainer.style.display="block",this.secondTitle.innerText=t.popup_title;let e="";e=`\n
${t.email_confirmation_text}
hogehoge@hoge.com
\n
`,this.secondContent.innerHTML=e,this.secondContent.style.color=t.text_color,this.secondContainer.style.backgroundColor=t.background_color,this.secondContainer.style.borderRadius=`${t.button_radius}px`,this.secondContainer.style.marginTop="20px",this.secondContainer.style.width="100%",this.secondFooter&&0!==this.secondFooter.children.length&&(this.secondFooter.innerHTML="");const n=document.createElement("button");n.className="storecrm_modal__btn storecrm_modal__btn-primary",n.innerHTML=t.button_text,n.style.backgroundColor=t.button_background_color,n.style.color=t.button_text_color,null===(i=this.secondFooter)||void 0===i||i.appendChild(n)}else this.secondContainer&&(this.secondContainer.style.display="none");this.preview||null===(r=document.getElementById("storecrm-modal-second-popup-preview"))||void 0===r||r.remove(),this.preview&&(this.success(this.config.success_text),this.failure(this.config.error_text),this.popup&&this.popup.querySelectorAll(".storecrm_modal__overlay,.storecrm_modal__close").forEach((t=>{t.addEventListener("click",(t=>{t.preventDefault(),t.stopPropagation()}))})))}resetMessage(){var t,e;this.footer&&(null===(t=this.footer)||void 0===t||t.querySelectorAll(".storecrm_modal_message").forEach((t=>t.remove()))),this.preview&&this.secondFooter&&(null===(e=this.secondFooter)||void 0===e||e.querySelectorAll(".storecrm_modal_message").forEach((t=>t.remove())))}disableButton(){this.button&&(this.button.setAttribute("disabled","disabled"),this.button.innerText="Sending...")}enableButtion(){this.button&&(this.button.removeAttribute("disabled"),this.button.innerText=this.config.button_text||"Enable Restock Notification")}submit(t=!1){var e,n,o;if(this.preview)return;this.resetMessage(),this.disableButton();const i=null===(e=this.content)||void 0===e?void 0:e.querySelector("#storecrm_restock_email"),r=null===(n=this.content)||void 0===n?void 0:n.querySelector("#storecrm_restock_variant"),s=null===(o=this.content)||void 0===o?void 0:o.querySelector("#storecrm_restock_accepts_marketing"),a=i?i.value:"",c=r?r.value:"",l=this.product_id,d=s?s.checked:null;this.parent&&this.parent.storeRestock(a,c,l,d,this.config.add_accepts_marketing_checkbox,t,this.success.bind(this),this.failure.bind(this))}show(t,e,n){this.product_id=n,this.inited?this.runShow(t,e):window.setTimeout(this.show.bind(this),100)}runShow(t,e){this.render(t,e),i.default.show("storecrm-modal")}hide(){i.default.close("storecrm-modal")}success(t){this.enableButtion();const e=document.createElement("div");e.classList.add("storecrm_modal_success","storecrm_modal_message"),e.style.color=this.config.success_text_color,e.style.backgroundColor=this.config.success_background_color,e.innerText=t,this.showSecondPopup?this.secondFooter&&this.secondFooter.appendChild(e):this.footer&&this.footer.appendChild(e)}failure(t){this.enableButtion();const e=document.createElement("div");e.classList.add("storecrm_modal_error","storecrm_modal_message"),e.style.color=this.config.failure_text_color,e.style.backgroundColor=this.config.failure_background_color,e.innerText=t,this.showSecondPopup?this.secondFooter&&this.secondFooter.appendChild(e):this.footer&&this.footer.appendChild(e)}checkAcceptsMarketingStatusAndClearMessages(){var t;if(this.resetMessage(),!this.config.add_accepts_marketing_checkbox)return void this.submit(!1);const e=null===(t=this.content)||void 0===t?void 0:t.querySelector("#storecrm_restock_email");this.parent.doMailCheck(e.value,this.failure.bind(this)).then((t=>{t.email?t.accepts_marketing?this.submit(!1):this.showAcceptsMarketingCheckbox(!1):this.showAcceptsMarketingCheckbox(!0)}))}showAcceptsMarketingCheckbox(t){var e;const n=document.getElementById("storecrm-modal-content"),o=null===(e=this.content)||void 0===e?void 0:e.querySelector("#storecrm_restock_email"),i=document.getElementById("accepts_marketing_checkbox_container"),r=document.getElementById("email_confirmation_container");if(!n||!i||!r)return;r.innerHTML=this.config.email_confirmation_text+"
"+o.value;const s=Array.from(n.children);s.forEach((t=>{"none"!==t.style.display&&t.classList.add("fade-out")})),setTimeout((()=>{s.forEach((t=>{t.style.display="none"}))}),300),i.classList.add("fade-in"),setTimeout((()=>{i.style.display="block"}),300),r.classList.add("fade-in"),setTimeout((()=>{r.style.display="block"}),300),this.switchSubmitButton(t)}switchSubmitButton(t){var e;this.footer&&(this.footer.innerHTML="");const n=document.createElement("button");n.className="storecrm_modal__btn storecrm_modal__btn-primary",n.style.color=this.config.button_text_color,n.style.backgroundColor=this.config.button_background_color,n.innerHTML=this.config.button_text,this.footer&&this.footer.appendChild(n),this.button=n,null===(e=this.button)||void 0===e||e.addEventListener("click",(()=>{this.submit(t)}))}}e.RestockPopupManager=r,r.template='';let s=null;e.schema={preview:(t,e)=>{var n,o;return n=()=>{r.getInstance(t,!0).show(t,[],"1234567890")},o=300,clearTimeout(s),s=setTimeout(n,o),r.template},rows:[{type:"text",slug:"popup_title",nameJa:"\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u306e\u30bf\u30a4\u30c8\u30eb",nameEn:"Popup title",defaultJa:"\u518d\u5165\u8377\u901a\u77e5",defaultEn:"Restock Notification"},{type:"text",slug:"popup_description",nameJa:"\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u306e\u672c\u6587",nameEn:"Popup description",defaultJa:"\u518d\u5165\u8377\u901a\u77e5\u3092\u3054\u5e0c\u671b\u306e\u65b9\u306f\u4ee5\u4e0b\u304b\u3089\u3001\u3054\u9078\u629e\u304f\u3060\u3055\u3044\u3002",defaultEn:"If you would like to receive a restock notification, please select from below."},{type:"text",slug:"emailaddress",nameJa:"\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u30d5\u30a9\u30fc\u30e0\u540d",nameEn:"Email address form name",defaultJa:"\u3054\u9023\u7d61\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9",defaultEn:"Contact Email Address"},{type:"colorpicker",slug:"background_color",nameJa:"\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u306e\u80cc\u666f\u8272",nameEn:"Popup background color",default:"#ffffff"},{type:"colorpicker",slug:"text_color",nameJa:"\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u306e\u30c6\u30ad\u30b9\u30c8\u8272",nameEn:"Popup text color",default:"#000000"},{type:"colorpicker",slug:"close_text_color",nameJa:"\u9589\u3058\u308b\u30dc\u30bf\u30f3\u306e\u8272",nameEn:"Popup close button text color",default:"#000000"},{type:"colorpicker",slug:"button_background_color",nameJa:"\u30dc\u30bf\u30f3\u306e\u80cc\u666f\u8272",nameEn:"buttonHoverColor",default:"#222222"},{type:"colorpicker",slug:"button_text_color",nameJa:"\u30dc\u30bf\u30f3\u306e\u30c6\u30ad\u30b9\u30c8\u30ab\u30e9\u30fc",nameEn:"buttonHoverBackgroundColor",default:"#dddddd"},{type:"text",slug:"button_text",nameJa:"\u30dc\u30bf\u30f3\u306e\u30c6\u30ad\u30b9\u30c8",nameEn:"buttonText",defaultJa:"\u518d\u5165\u8377\u901a\u77e5\u3092\u6709\u52b9\u306b\u3059\u308b",defaultEn:"Enable restock notification"},{type:"text",slug:"success_text",nameJa:"\u6210\u529f\u6642\u306e\u30c6\u30ad\u30b9\u30c8",nameEn:"Success text",defaultJa:"\u518d\u5165\u8377\u901a\u77e5\u304c\u767b\u9332\u3055\u308c\u307e\u3057\u305f\u3002",defaultEn:"Restock notification has been registered."},{type:"colorpicker",slug:"success_background_color",nameJa:"\u6210\u529f\u6642\u306e\u80cc\u666f\u8272",nameEn:"Success background color",default:"#F0FDF4"},{type:"colorpicker",slug:"success_text_color",nameJa:"\u6210\u529f\u6642\u306e\u6587\u5b57\u8272",nameEn:"Success text color",default:"#166534"},{type:"text",slug:"error_text",nameJa:"\u5931\u6557\u6642\u306e\u30c6\u30ad\u30b9\u30c8",nameEn:"Error text",defaultJa:"\u518d\u5165\u8377\u901a\u77e5\u306e\u767b\u9332\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002\u3057\u3070\u3089\u304f\u305f\u3063\u3066\u304b\u3089\u518d\u5ea6\u304a\u8a66\u3057\u304f\u3060\u3055\u3044\u3002",defaultEn:"Failed to register restock notification. Please try again later."},{type:"text",slug:"error_text_email",nameJa:"\u5931\u6557\u6642\u306e\u30c6\u30ad\u30b9\u30c8(\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306e\u5224\u5b9a)",nameEn:"Error text",defaultJa:"\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u304c\u6b63\u3057\u304f\u3042\u308a\u307e\u305b\u3093\u3002\u78ba\u8a8d\u306e\u4e0a\u3001\u518d\u5ea6\u3054\u8a18\u5165\u304f\u3060\u3055\u3044\u3002",defaultEn:"The email address is incorrect. Please check and re-enter."},{type:"colorpicker",slug:"failure_background_color",nameJa:"\u30a8\u30e9\u30fc\u6642\u306e\u80cc\u666f\u8272",nameEn:"Success background color",default:"#FEF2F2"},{type:"colorpicker",slug:"failure_text_color",nameJa:"\u30a8\u30e9\u30fc\u6642\u306e\u6587\u5b57\u8272",nameEn:"Success text color",default:"#991B1B"},{type:"range",slug:"button_radius",nameJa:"\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u306e\u4e38\u307f",nameEn:"buttonRadius",default:10,min:0,max:40,step:1},{type:"checkbox",slug:"add_accepts_marketing_checkbox",nameJa:"\u30e1\u30eb\u30de\u30ac\u914d\u4fe1\u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9\u3092\u6709\u52b9\u5316",nameEn:"Add accepts marketing checkbox",default:!1},{type:"text",slug:"accepts_marketing_checkbox_text",nameJa:"\u30e1\u30eb\u30de\u30ac\u914d\u4fe1\u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9\u306e\u30c6\u30ad\u30b9\u30c8",nameEn:"Accepts marketing checkbox text",defaultJa:"\u30e1\u30eb\u30de\u30ac\u914d\u4fe1\u306b\u540c\u610f\u3059\u308b",defaultEn:"I agree to receive marketing emails"},{type:"text",slug:"email_confirmation_text",nameJa:"\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u78ba\u8a8d\u30c6\u30ad\u30b9\u30c8",nameEn:"Email confirmation text",defaultJa:"\u3053\u3061\u3089\u306e\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3067\u9593\u9055\u3044\u306a\u3044\u3067\u3059\u304b\uff1f",defaultEn:"Is this the correct email address?"}]}},898:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.schema=e.generateDefaultSettings=e.render=e.RestockButton=void 0;class n{constructor(t,e,n,o,i){this.eventTriggered=!1,this.variants=n,this.buttonSettings=o,this.productId=e,this.product=i}static getInstance(t,e=null,o=null,i=null,r=null){if(n.instances[t])i&&(n.instances[t].buttonSettings=i);else{if(!(e&&o&&i&&r))throw new Error("StoreCRM Restock: productId, variants, buttonSettings, product are required");n.instances[t]=new n(t,e,o,i,r)}return n.instances[t]}createScript(t,e){const n=t?"":"onclick=\"event.preventDefault();window.storecrm ? window.storecrm.showRestock(this) : alert('\u8aad\u8fbc\u4e2d\u3067\u3059\u3002\u3057\u3070\u3089\u304f\u305f\u3063\u3066\u304b\u3089\u518d\u5ea6\u304a\u8a66\u3057\u304f\u3060\u3055\u3044\u3002');\"";return`\n\n\n
\n\n
\n `}checkRender(t){document.querySelectorAll(`.storecrm-restock-${t}`).forEach((t=>{var e;if(t instanceof HTMLElement&&t.closest('[data-type="restock-button"]')){const n=new URL(location.href),o=(null===(e=this.variants.find((t=>t.available)))||void 0===e?void 0:e.id)||this.variants[0].id||null,i=parseInt(n.searchParams.get("variant")||o,10);if(!i)return void console.error("StoreCRM Restock: variantId is not set",i);if(!this.product||!this.product.tags||this.product.tags.indexOf("storecrm-restock-hidden")>=0)return console.error("StoreCRM: Restock:product not found or hidden"),void(t.style.display="none");const r=window.Shopify&&window.Shopify.designMode||this.variants.find((t=>!t.available&&t.id===i));t.style.display=r?"inline-block":"none"}}))}render(t,e=!1){if(e)return this.createScript(!0,t);if(!this.eventTriggered){if(this.eventTriggered=!0,window.navigation)window.navigation.addEventListener("navigate",(()=>{window.setTimeout((()=>this.checkRender(t)),100)})),window.setTimeout((()=>this.checkRender(t)),100),window.setTimeout((()=>this.checkRender(t)),1e3);else{let e=location.href;window.setInterval((()=>{e!==location.href&&(e=location.href,this.checkRender(t))}),1e3),window.setTimeout((()=>this.checkRender(t)),100),window.setTimeout((()=>this.checkRender(t)),1e3)}return this.createScript(!1,t)}}}e.RestockButton=n,n.instances={};e.render=({productId:t,variantId:e,variants:o,id:i,buttonSettings:r,isOutOfStock:s,product:a,preview:c=!1})=>n.getInstance(i,t,o,r,a).render(i,c);e.generateDefaultSettings=(t="ja")=>{const n={};return e.schema.rows.forEach((e=>{"text"===e.type?n[e.slug]="ja"===t?e.defaultJa:e.defaultEn:(e.type,n[e.slug]=e.default)})),n},e.schema={preview:(t,n)=>(0,e.render)({productId:"TEMP_productId",id:"TEMP_restock",buttonSettings:t,isOutOfStock:!1,preview:!0,product:{tags:[]},variants:[]}),rows:[{type:"text",slug:"button_text",nameJa:"\u30dc\u30bf\u30f3\u306e\u30c6\u30ad\u30b9\u30c8",nameEn:"buttonText",defaultJa:"\u518d\u5165\u8377\u901a\u77e5\u3092\u53d7\u3051\u53d6\u308b",defaultEn:"Notify restock"},{type:"range",slug:"button_width",nameJa:"\u30dc\u30bf\u30f3\u306e\u5e45",nameEn:"buttonWidth",default:200,min:50,max:600,step:10},{type:"range",slug:"button_height",nameJa:"\u30dc\u30bf\u30f3\u306e\u9ad8\u3055",nameEn:"buttonHeight",default:50,min:30,max:100,step:5},{type:"colorpicker",slug:"button_color",nameJa:"\u30dc\u30bf\u30f3\u306e\u6587\u5b57\u8272",nameEn:"buttonColor",default:"#000000"},{type:"colorpicker",slug:"button_background_color",nameJa:"\u30dc\u30bf\u30f3\u306e\u80cc\u666f\u8272",nameEn:"buttonBackgroundColor",default:"#ffffff"},{type:"colorpicker",slug:"button_border_color",nameJa:"\u30dc\u30bf\u30f3\u306e\u7dda\u306e\u8272",nameEn:"buttonBorderColor",default:"#000000"},{type:"colorpicker",slug:"button_hover_color",nameJa:"\u30dc\u30bf\u30f3\u306e\u6587\u5b57\u8272(\u30db\u30d0\u30fc\u6642)",nameEn:"buttonHoverColor",default:"#222222"},{type:"colorpicker",slug:"button_hover_background_color",nameJa:"\u30dc\u30bf\u30f3\u306e\u80cc\u666f\u8272(\u30db\u30d0\u30fc\u6642)",nameEn:"buttonHoverBackgroundColor",default:"#dddddd"},{type:"colorpicker",slug:"button_hover_border_color",nameJa:"\u30dc\u30bf\u30f3\u306e\u7dda\u306e\u8272(\u30db\u30d0\u30fc\u6642)",nameEn:"buttonHoverBorderColor",default:"#222222"},{type:"range",slug:"button_radius",nameJa:"\u30dc\u30bf\u30f3\u306e\u4e38\u307f",nameEn:"buttonRadius",default:0,min:0,max:20,step:1},{type:"range",slug:"button_border_width",nameJa:"\u30dc\u30bf\u30f3\u306e\u7dda\u306e\u592a\u3055",nameEn:"buttonBorderWidth",default:0,min:0,max:5,step:1},{type:"fontpicker",slug:"button_font",nameJa:"\u30dc\u30bf\u30f3\u306e\u30d5\u30a9\u30f3\u30c8",nameEn:"buttonFont",default:"helvetica_n4"},{type:"range",slug:"button_fontsize",nameJa:"\u30dc\u30bf\u30f3\u306e\u30d5\u30a9\u30f3\u30c8\u30b5\u30a4\u30ba",nameEn:"buttonFontSize",default:16,min:10,max:30,step:1},{type:"range",slug:"button_fontweight",nameJa:"\u30dc\u30bf\u30f3\u306e\u30d5\u30a9\u30f3\u30c8\u30a6\u30a7\u30a4\u30c8",nameEn:"buttonFontWeight",default:400,min:100,max:900,step:100},{type:"range",slug:"button_speed",nameJa:"\u30dc\u30bf\u30f3\u306e\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u901f\u5ea6",nameEn:"buttonSpeed",default:.3,min:0,max:1,step:.1},{type:"select",slug:"align",nameJa:"\u30dc\u30bf\u30f3\u306e\u914d\u7f6e",nameEn:"align",default:"center",defaultJa:"\u4e2d\u592e\u5bc4\u305b",defaultEn:"Center",selectOptionsJa:[{value:"left",label:"\u5de6\u5bc4\u305b"},{value:"center",label:"\u4e2d\u592e\u5bc4\u305b"},{value:"right",label:"\u53f3\u5bc4\u305b"}],selectOptionsEn:[{value:"left",label:"Align left"},{value:"center",label:"Align center"},{value:"right",label:"Align right"}]}]}},247:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StatusWidget=void 0;e.StatusWidget=class{constructor(t,e,n){this.position="beforeend",this.header=t,this.config=n,this.position=e}setParent(t){this.parent=t}render(){this.parent&&this.parent.getStatus((t=>{this.renderedWidget&&(this.renderedWidget.remove(),this.renderedWidget=void 0),this.renderedWidget=this.createWidget(t),this.header.insertAdjacentElement(this.position,this.renderedWidget)}),(t=>{console.error("StoreCRM: StatusWidget render failed",t)})),this.parent||console.error("StoreCRM render: no parent. Abort.")}isLineVisible(t){return t.line_show_account&&(!t.line_debug_account||document.querySelector("#OnlineStorePreviewBarNextData")||window.Shopify.designMode)}createWidget(t){var e,n,o,i;const r=document.createElement("div");function s(t){const e=document.createElement("span");return e.classList.add("storecrm-off"),e.appendChild(document.createTextNode(t)),e}function a(t){const e=document.createElement("span");return e.classList.add("storecrm-on"),e.appendChild(document.createTextNode(t)),e}function c(t){const e=document.createElement("button");return e.classList.add("storecrm-button","storecrm-button-off"),e.appendChild(document.createTextNode(t)),e}function l(t){const e=document.createElement("button");return e.classList.add("storecrm-button","storecrm-button-on"),e.appendChild(document.createTextNode(t)),e}if(r.classList.add("storecrm-status-widget"),this.isLineVisible(t)){const o=document.createElement("div");o.appendChild(document.createTextNode("LINE\u8a2d\u5b9a: ")),o.appendChild(t.line?a("\u8a2d\u5b9a\u6e08"):s("\u672a\u767b\u9332")),this.lineButton=t.line?c("\u89e3\u9664\u3059\u308b"):l("\u767b\u9332\u3059\u308b"),o.appendChild(this.lineButton),r.appendChild(o),t.line?null===(e=this.lineButton)||void 0===e||e.addEventListener("click",this.lineUnsubscribe.bind(this)):null===(n=this.lineButton)||void 0===n||n.addEventListener("click",this.lineSubscribe.bind(this))}if(t.mail_show_account){const e=document.createElement("div");e.appendChild(document.createTextNode("\u30e1\u30fc\u30eb\u30de\u30ac\u30b8\u30f3: ")),e.appendChild(t.accepts_marketing?a("\u8cfc\u8aad\u4e2d"):s("\u672a\u8cfc\u8aad")),this.mailButton=t.accepts_marketing?c("\u8cfc\u8aad\u89e3\u9664\u3059\u308b"):l("\u8cfc\u8aad\u3059\u308b"),e.appendChild(this.mailButton),r.appendChild(e),t.accepts_marketing?null===(o=this.mailButton)||void 0===o||o.addEventListener("click",this.unsubscribe.bind(this)):null===(i=this.mailButton)||void 0===i||i.addEventListener("click",this.subscribe.bind(this))}return r}lineSubscribe(){this.parent&&this.parent.lineSubscribe((function(t){alert(t)}))}lineUnsubscribe(){this.parent&&this.parent.lineUnsubscribe((function(t){alert(t)}))}subscribe(){this.parent&&this.parent.mailSubscribe((function(t){alert(t)}))}unsubscribe(){this.parent&&this.parent.mailUnsubscribe((function(t){alert(t)}))}}},398:function(t,e,n){var o=this&&this.__awaiter||function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{c(o.next(t))}catch(t){r(t)}}function a(t){try{c(o.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((o=o.apply(t,e||[])).next())}))},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=n(989),s=n(898),a=n(392),c=n(435),l=n(209),d=n(247),u=n(158),h=i(n(700));n(511);e.default=class{constructor(t){this.statusWidget=void 0,this.isTokenRefreshed=!1,this.isTokenFetching=!1,this.favoriteMode="product",this.favoriteKey="products",window.storecrm_data=window.storecrm_data||{},console.log("StoreCRM initialized version 0.7.18",t),this.config=t,this.fillDefault(),this.popupManager=c.RestockPopupManager.getInstance(t.restockPopup),this.popupManager.setParent(this),this.lineRestockPopupManager=l.LineRestockPopupManager.getInstance(t.lineRestockPopup),this.lineRestockPopupManager.setParent(this)}init(){(()=>{o(this,void 0,void 0,(function*(){try{yield this.checkCustomer(),window.localStorage.getItem("storecrm_wishlist")||(yield this.syncWishlist())}catch(t){console.error("StoreCRM: init: error",t)}yield this.render(),window.location.pathname.startsWith("/apps/")&&(yield this.renderFavoriteList())}))})(),window.addEventListener("pageshow",(t=>{t.persisted&&this.render(!0)})),document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&this.render(!0)})),this.initLineLogin()}initLineLogin(){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(()=>{this.executeLineLoginInit()})):this.executeLineLoginInit()}executeLineLoginInit(){if(h.default.isLoginOrRegisterPage()){new h.default(this).init()}}getCurrentShopifyCustomerId(){try{return window.storecrm_data.customer_id||window.ShopifyAnalytics.meta.page.customerId}catch(t){return null}}checkCustomer(){return o(this,void 0,void 0,(function*(){if(window.storecrm_data.is_customer_checked)return;window.storecrm_data.is_customer_checked=!0;const t=(window.localStorage.getItem("storecrm_customer_id")||"").toString(),e=(this.getCurrentShopifyCustomerId()||"").toString();if(t!==e){if(e)return!t||t.startsWith("TEMP_")&&e?(yield this.refreshToken(!1),void(yield this.syncWishlist(null,t,!0))):void(t===e||(yield this.refreshToken(!0)));(null==t?void 0:t.startsWith("TEMP_"))||(yield this.refreshToken(!0))}}))}refreshToken(){return o(this,arguments,void 0,(function*(t=!1){return t&&(window.localStorage.removeItem("storecrm_customer_id"),window.localStorage.removeItem("storecrm_wishlist")),yield this.fetchToken()}))}fillDefault(){this.config.favorite=this.config.favorite||{},r.schema.rows.forEach((t=>{this.config.favorite[t.slug]=this.config.favorite[t.slug]||t.default||t.defaultEn})),this.favoriteMode=this.config.favorite.favoriteMode||"product",this.favoriteKey="product"===this.favoriteMode?"products":"variants",console.log("StoreCRM: Current favorite mode: ",this.favoriteMode),this.config.restock=this.config.restock||{},s.schema.rows.forEach((t=>{this.config.restock[t.slug]=this.config.restock[t.slug]||t.default||t.defaultEn})),this.config.restockPopup=this.config.restockPopup||{},c.schema.rows.forEach((t=>{this.config.restockPopup[t.slug]=this.config.restockPopup[t.slug]||t.default||t.defaultEn})),this.config.lineRestockPopup=this.config.lineRestockPopup||{},l.schema.rows.forEach((t=>{this.config.lineRestockPopup[t.slug]=this.config.lineRestockPopup[t.slug]||t.default||t.defaultEn}))}render(t=!1){this.doRender(t),t||(window.setTimeout(this.doRender.bind(this),500),window.setTimeout(this.doRender.bind(this),2e3),window.setTimeout(this.doRender.bind(this),5e3))}doRender(t=!1){window.location.pathname.startsWith("/apps")&&window.location.pathname.endsWith("/connect")&&(this.checkConnect(),this.renderStatusWidget());const e=JSON.parse(window.localStorage.getItem("storecrm_wishlist")||"{}");e[this.favoriteKey]||(e[this.favoriteKey]=[]),document.querySelectorAll(".storecrm-button").forEach((t=>{if(t instanceof HTMLElement==!1)return;const n=t.id||"storecrm-button-"+Math.random().toString(36).slice(-8);t.id||(t.id=n);const o=new URL(location.href),i=o.searchParams.get("variant")&&o.searchParams.get("variant"),c=t.dataset.productId,l=i||t.dataset.variantId,d=void 0!==t.dataset.variantSelector,u=JSON.parse(t.dataset.variants||"[]"),h={tags:JSON.parse(t.dataset.productTags||"[]"),id:t.dataset.productId};if(!h||!c||!l)return void console.error("StoreCRM: product or productId or variantId is not set",c,l);const m=e&&("product"==this.favoriteMode?e.products&&e.products.includes(c):e.variants&&e.variants.includes(l)),p=!!t.dataset.currentVariantAvailable,f="wishlist-button"===t.dataset.type?(0,r.render)({productId:c,variantId:l,id:n,button:t,variants:u,product:h,buttonSettings:this.config.favorite,isFavorited:m,hasVariantSelector:d}):"line-restock-button"===t.dataset.type?(0,a.render)({productId:c,variantId:l,id:n,buttonSettings:this.config.lineRestock||(0,a.generateDefaultSettings)(),isOutOfStock:p,product:h,variants:u}):(0,s.render)({productId:c,variantId:l,id:n,buttonSettings:this.config.restock,isOutOfStock:p,product:h,variants:u});f&&(t.innerHTML=f)})),document.querySelectorAll(".storecrm-favorite").forEach((n=>{if(n instanceof HTMLElement==!1)return;if(!t&&"true"===n.dataset.isRendered)return;n.dataset.isRendered="true";const o=n.dataset.productId||"",i=n.dataset.variantId||"";if(!o)return;const s=void 0!==n.dataset.variantSelector,a=n.id||"storecrm-favorite-"+Math.random().toString(36).slice(-8);n.id||(n.id=a);const c=JSON.parse(n.dataset.variants||"[]"),l={tags:JSON.parse(n.dataset.productTags||"[]"),id:n.dataset.productId},d=e&&e.products&&e.products.includes(o);n.innerHTML=(0,r.render)({productId:o,variantId:i,button:n,id:a,buttonSettings:this.config.favorite,isFavorited:d,hasVariantSelector:s,variants:c,product:l})||""})),"/account"!==window.location.pathname&&"/account/"!==window.location.pathname||this.renderStatusWidget(),this.checkToken()}checkToken(){this.isTokenRefreshed||this.isTokenRefreshNeeded()&&this.fetchToken()}isTokenRefreshNeeded(){const t=window.localStorage.getItem("storecrm_customer_id"),e=parseInt(window.localStorage.getItem("storecrm_customer_id")||"0",10),n=window.localStorage.getItem("storecrm_token");let o=null;try{o=n?n.split("|")[1]:null}catch(t){}return this.isTokenRefreshed?(console.log("StoreCRM: Token refresh needed: false (already refreshed)"),!1):t&&n&&o?window.ShopifyAnalytics&&window.ShopifyAnalytics.meta&&window.ShopifyAnalytics.meta.page&&window.ShopifyAnalytics.meta.page.customerId&&window.ShopifyAnalytics.meta.page.customerId!==e?(console.log("StoreCRM: Token refresh needed: true (customerId mismatch)"),!0):window.ShopifyAnalytics&&window.ShopifyAnalytics.meta&&window.ShopifyAnalytics.meta.page&&window.ShopifyAnalytics.meta.page.customerId?1e3*parseFloat(o)<(new Date).getTime()&&(console.log("StoreCRM: Token refresh needed: true (expired)"),!0):(console.log("StoreCRM: Token refresh needed: true (no customerId)"),!0):(console.log("StoreCRM: Token refresh needed: true (no token)"),!0)}fetchToken(){return o(this,void 0,void 0,(function*(){if(this.isTokenFetching)return yield new Promise((t=>{const e=setInterval((()=>{this.isTokenFetching||(clearInterval(e),t(null))}),100)})),window.localStorage.getItem("storecrm_token");this.isTokenFetching=!0;const t=window.localStorage.getItem("storecrm_customer_id"),e=yield fetch(`/apps/${this.config.appProxyName}/token?current_customer_id=${t}`),n=(yield e.text()).match(/\[data\]([\s\S]*?)\[\/data\]/);if(!n)throw this.isTokenRefreshed=!0,new Error("No data from API");const o=JSON.parse(n[1]);if(!o||!o.customer)throw this.isTokenRefreshed=!0,new Error("No data from API2");return window.localStorage.setItem("storecrm_token",o.customer.token),window.localStorage.setItem("storecrm_customer_id",o.customer.id),this.isTokenRefreshed=!0,(null==t?void 0:t.startsWith("TEMP_"))&&o.customer.id!==t&&(yield this.syncWishlist(null,t)),this.isTokenFetching=!1,o.customer.token}))}getToken(){return o(this,void 0,void 0,(function*(){return this.isTokenFetching&&(yield this.fetchToken()),window.localStorage.getItem("storecrm_token")}))}getCustomerId(){return o(this,void 0,void 0,(function*(){return this.isTokenFetching&&(yield this.fetchToken()),window.localStorage.getItem("storecrm_customer_id")}))}request(){return o(this,arguments,void 0,(function*(t="GET",e,n=null,o=!1){const i=yield this.getCustomerId(),r=yield this.getToken(),s=window.location.href;e.includes("?")?e+=`&customer_id=${i}&host=${window.location.host}&referrer=${encodeURIComponent(s)}`:e+=`?customer_id=${i}&host=${window.location.host}&referrer=${encodeURIComponent(s)}`;const a=yield fetch(e,{method:t,headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:n?JSON.stringify(n):null,credentials:o?"include":"same-origin"});if(!a.ok)throw new Error("API request failed");return a.json()}))}toggleWishlist(t,e=!1,n=!1,o=""){n?this.fetchToken().then((()=>{var n=window.localStorage.getItem("storecrm_customer_id");n&&!/^TEMP_/.test(n)?this.doToggleWishlist(t,!e).then((()=>{})).catch((t=>{console.error(t),alert("\u30b5\u30fc\u30d0\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\uff01 error: "+t.message+" \u3057\u3070\u3089\u304f\u305f\u3063\u3066\u304b\u3089\u518d\u5ea6\u304a\u8a66\u3057\u304f\u3060\u3055\u3044\u3002")})):window.location.href=""===o?"/account/login":o})):this.doToggleWishlist(t,!e).then((()=>{})).catch((t=>{console.error(t),alert("\u30b5\u30fc\u30d0\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\uff01 error: "+t.message+" \u3057\u3070\u3089\u304f\u305f\u3063\u3066\u304b\u3089\u518d\u5ea6\u304a\u8a66\u3057\u304f\u3060\u3055\u3044\u3002")}))}syncWishlist(){return o(this,arguments,void 0,(function*(t=null,e=void 0,n=!1){if(!n){const t=JSON.parse(window.localStorage.getItem("storecrm_wishlist")||"{}");if(t.lastUpdated&&Date.now()-t.lastUpdated<12e5)return t}let o=null;try{o=t||(yield this.getWishlist(e))}catch(t){return void console.error("StoreCRM: syncWishlist: error",t)}if(!o||!(this.favoriteKey in o))return void console.error("StoreCRM: Invalid response from favorite fetch API",o);window.localStorage.getItem("storecrm_wishlist");return"product"===this.favoriteMode?(window.localStorage.setItem("storecrm_wishlist",JSON.stringify({products:o.products,lastUpdated:Date.now()})),this.renderFavoriteList(),{products:o.products}):(window.localStorage.setItem("storecrm_wishlist",JSON.stringify({products:o.products,variants:o.variants,lastUpdated:Date.now()})),this.renderFavoriteList(),{products:o.products,variants:o.variants})}))}renderFavoriteList(){return o(this,void 0,void 0,(function*(){const t=document.querySelector(".storecrm_favoritelist");if(!t||t instanceof HTMLElement==!1)return;const e=u.Renderer.getInstance(this);yield e.init(),yield e.render()}))}getWishlist(){return o(this,arguments,void 0,(function*(t=void 0){return t?this.request("GET",`${this.config.backendUrl}/frontend/favorite/?old_customer_id=${t}&mode=${this.favoriteMode}`):this.request("GET",`${this.config.backendUrl}/frontend/favorite/?mode=${this.favoriteMode}`)}))}doToggleWishlist(t){return o(this,arguments,void 0,(function*(t,e=!1){const n=t.dataset.productId;let o=t.dataset.variantId;const i=void 0!==t.dataset.variantSelector;if(!n)return void console.error("Product ID not found");const s=t.closest(".storecrm-favorite"),a=s&&JSON.parse(s.dataset.variants||"null");if("variant"==this.favoriteMode&&a&&1===a.length&&(o=a[0].id,(0,r.hideWidgetSelector)()),"variant"==this.favoriteMode&&!o){if(i){const e=JSON.parse(window.localStorage.getItem("storecrm_wishlist")||"{}");return void(0,r.renderWidgetSelector)({button:t,productId:n,variants:a,wishlist:e,buttonSettings:this.config.favorite})}return void console.error("Variant ID not found: you need to set data-variant-id (Specify variant id) or data-variant-selector(Show variant selector) attribute.")}let c={};c=e?yield this.request("POST",`${this.config.backendUrl}/frontend/favorite/`,{product_id:n,variant_id:o,mode:this.favoriteMode}):yield this.request("DELETE",`${this.config.backendUrl}/frontend/favorite/?product_id=${n}&variant_id=${o}&mode=${this.favoriteMode}`),c&&window.localStorage.setItem("storecrm_wishlist",JSON.stringify(Object.assign(Object.assign({},c),{lastUpdated:Date.now()}))),"variant"==this.favoriteMode&&i&&(0,r.renderWidgetSelector)({button:t,productId:n,variants:a,wishlist:c,buttonSettings:this.config.favorite,rerender:!0}),this.render(!0),this.renderFavoriteList()}))}showRestock(t){const e=t.dataset.id||t.id,n=s.RestockButton.getInstance(e);n?this.popupManager.show(this.config.restockPopup,n.variants,n.productId):console.error("StoreCRM Restock: restockButton not found")}showLineRestockPopup(t){return o(this,void 0,void 0,(function*(){var e;const n=a.LineRestockButton.getInstance(t);if(n)if(null===(e=window.storecrm_data)||void 0===e?void 0:e.customer_id){const t=yield this.doGetLineProfile();this.lineRestockPopupManager.show(this.config.lineRestockPopup,n.variants,n.productId,t)}else this.lineRestockPopupManager.show(this.config.lineRestockPopup,n.variants,n.productId,void 0);else console.error("StoreCRM LineRestock: lineRestockButton not found")}))}storeRestock(t,e,n,o,i,r,s=void 0,a=void 0){if(!this.checkEmailFormat(t))return a&&a("\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u304c\u6b63\u3057\u304f\u3042\u308a\u307e\u305b\u3093\u3002");this.doStoreRestock(e,n,t,i,o,r).then((()=>{s&&s(this.config.restockPopup.success_text)})).catch((t=>{console.error("StoreCRM: API call failed:",t),a&&a(this.config.restockPopup.error_text)}))}doStoreRestock(t,e,n,i,r,s){return o(this,void 0,void 0,(function*(){if(i)try{yield this.doUpsertCustomerAcceptsMarketing(n,r,s)}catch(t){console.error("API call failed:",t)}return yield this.request("POST",`${this.config.backendUrl}/frontend/restock/`,{product_id:e,variant_id:t,email:n})}))}storeLineRestock(t,e,n,o,i,r=void 0,s=void 0){this.doStoreLineRestock(t,e,n,o,i).then((()=>{r&&r(this.config.lineRestockPopup.success_text)})).catch((t=>{console.error("StoreCRM: API call failed:",t),s&&s(this.config.lineRestockPopup.error_text)}))}doStoreLineRestock(t,e,n,i,r){return o(this,void 0,void 0,(function*(){return yield this.request("POST",`${this.config.backendUrl}/frontend/line/restock/`,{product_id:t,variant_id:e,line_customer_id:n,line_name:i,line_profile:r})}))}doUpsertCustomerAcceptsMarketing(t,e,n){return o(this,void 0,void 0,(function*(){return yield this.request("POST",`${this.config.backendUrl}/frontend/accepts-marketing/`,{email:t,accepts_marketing:e,new_customer:n})}))}doGetLineProfile(){return o(this,void 0,void 0,(function*(){return yield this.request("GET",`${this.config.backendUrl}/frontend/line/profile`)}))}renderStatusWidget(){if(this.statusWidget)return;const t=document.querySelector(".storecrm-status-widget-target"),e=document.querySelector("#shopify-section-header,.section-header,.section--header,header,.header-wrapper,.header,.header_nav"),n=document.querySelector("#MainContent, #main, .main, main");if(e||n||t){if(t)this.statusWidget=new d.StatusWidget(t,"beforeend",this.config);else if(n)this.statusWidget=new d.StatusWidget(n,"afterbegin",this.config);else{if(!e)return;this.statusWidget=new d.StatusWidget(e,"beforeend",this.config)}this.statusWidget.setParent(this),this.statusWidget.render()}else console.error("Shopify header not found. Please assign following class/id/element to header: #shopify-section-header,.section-header,.section--header,header,.header_nav")}getStatus(t,e){this.doGetStatus().then((e=>{t(e)})).catch((t=>{console.error(t),e("\u30b5\u30fc\u30d0\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002")}))}doGetStatus(){return o(this,void 0,void 0,(function*(){return yield this.request("GET",`${this.config.backendUrl}/frontend/status`)}))}lineSubscribe(t=void 0){this.doLineSubscribe()}doLineSubscribe(){return o(this,void 0,void 0,(function*(){const t=yield this.getCustomerId(),e=yield this.getToken(),n=window.location.href;location.href=`${this.config.backendUrl}/frontend/line/connect?token=${e}&customer_id=${t}&host=${window.location.host}&referrer=${encodeURIComponent(n)}`}))}doLineLogin(){return o(this,void 0,void 0,(function*(){const t=yield this.getCustomerId(),e=yield this.getToken(),n=window.location.href;location.href=`${this.config.backendUrl}/frontend/line/connect?is_multipass=true&token=${e}&customer_id=${t}&host=${window.location.host}&referrer=${encodeURIComponent(n)}`}))}lineUnsubscribe(t=void 0){this.doLineUnsubscribe().then((t=>{location.href=location.pathname+"?line_disconnect=1"})).catch((e=>{console.error(e),t?t("LINE\u306e\u901a\u77e5\u89e3\u9664\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002"):alert("LINE\u306e\u901a\u77e5\u89e3\u9664\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002")}))}doLineUnsubscribe(){return o(this,void 0,void 0,(function*(){return yield this.request("POST",`${this.config.backendUrl}/frontend/line/disconnect`)}))}mailSubscribe(){this.doMailSubscribe().then((t=>{console.log("StoreCRM: \u30e1\u30fc\u30eb\u30de\u30ac\u30b8\u30f3\u306e\u8cfc\u8aad\u306b\u6210\u529f\u3057\u307e\u3057\u305f\u3002",t),this.statusWidget&&this.statusWidget.render()})).catch((t=>{console.error(t),alert("\u30e1\u30fc\u30eb\u30de\u30ac\u30b8\u30f3\u306e\u8cfc\u8aad\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002")}))}doMailSubscribe(){return o(this,void 0,void 0,(function*(){return yield this.request("POST",`${this.config.backendUrl}/frontend/email/subscribe`)}))}mailUnsubscribe(){this.doMailUnsubscribe().then((t=>{console.log("StoreCRM: \u30e1\u30fc\u30eb\u30de\u30ac\u30b8\u30f3\u306e\u89e3\u9664\u306b\u6210\u529f\u3057\u307e\u3057\u305f\u3002",t);const e=document.getElementById("storecrm_message");e&&(e.innerHTML="\u30e1\u30fc\u30eb\u30de\u30ac\u30b8\u30f3\u306e\u89e3\u9664\u306b\u6210\u529f\u3057\u307e\u3057\u305f\u3002"),this.statusWidget&&this.statusWidget.render()})).catch((t=>{console.error(t);const e=document.getElementById("storecrm_message");e&&(e.innerHTML="\u30e1\u30fc\u30eb\u30de\u30ac\u30b8\u30f3\u306e\u89e3\u9664\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002","API"in t.toString()&&(e.innerHTML+='
\u89e3\u9664\u3092\u9032\u3081\u308b\u306b\u306f\u30ed\u30b0\u30a4\u30f3\u3092\u3057\u3066\u304f\u3060\u3055\u3044\u3002')),alert("\u30e1\u30fc\u30eb\u30de\u30ac\u30b8\u30f3\u306e\u89e3\u9664\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002")}))}doMailUnsubscribe(){return o(this,void 0,void 0,(function*(){return yield this.request("POST",`${this.config.backendUrl}/frontend/email/unsubscribe`)}))}doMailCheck(t){return o(this,arguments,void 0,(function*(t,e=void 0){if(!this.checkEmailFormat(t))return e&&e("\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u304c\u6b63\u3057\u304f\u3042\u308a\u307e\u305b\u3093\u3002");return yield this.request("GET",`${this.config.backendUrl}/frontend/accepts-marketing/?email=${encodeURIComponent(t)}`)}))}birthdaySet(){}checkEmailFormat(t){return!(!t||!t.match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|.(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/))}checkConnect(){const t=new URLSearchParams(window.location.search),e=t.get("storecrm"),n=window.localStorage.getItem("storecrm_customer_id");if(n&&!n.startsWith("TEMP_")){if("line_connect"===e?this.lineSubscribe((function(){console.log("StoreCRM: LINE\u306e\u901a\u77e5\u767b\u9332\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002")})):"line_disconnect"===e?this.lineUnsubscribe():"email_subscribe"===e?this.mailSubscribe():"email_unsubscribe"===e?this.mailUnsubscribe():"birthday_set"===e&&this.birthdaySet(),t.get("line_disconnect")){const t=document.querySelector("#storecrm_message");t&&(t.innerHTML="LINE\u306e\u901a\u77e5\u3092\u89e3\u9664\u3057\u307e\u3057\u305f\u3002")}if(t.get("line_connect")){const t=document.querySelector("#storecrm_message");t&&(t.innerHTML="LINE\u3092\u9023\u643a\u3057\u307e\u3057\u305f\u3002")}}else{const t=document.getElementById("storecrm_message");t&&(t.innerHTML='\u8a2d\u5b9a\u5909\u66f4\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002
\u9032\u3081\u308b\u306b\u306f\u30ed\u30b0\u30a4\u30f3\u3092\u3057\u3066\u304f\u3060\u3055\u3044\u3002')}}}},927:function(t,e,n){var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(398));window.storecrm=new i.default(window.storecrm_config||{}),window.storecrm.init()}},e={};function n(o){var i=e[o];if(void 0!==i)return i.exports;var r=e[o]={id:o,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.nc=void 0;n(927)})();